use a true randomness in the app
This commit is contained in:
3
core.css
3
core.css
@@ -32,9 +32,8 @@ main {
|
|||||||
|
|
||||||
.meaning {
|
.meaning {
|
||||||
color: #9f9a9a;
|
color: #9f9a9a;
|
||||||
font-style: italic;
|
|
||||||
font-weight: 100;
|
font-weight: 100;
|
||||||
font-size: 1.2rem;
|
font-size: 1rem;
|
||||||
}
|
}
|
||||||
|
|
||||||
.meaning::before {
|
.meaning::before {
|
||||||
|
|||||||
@@ -91,7 +91,8 @@ const feature: Feature = {
|
|||||||
Blue bins are your security stock, to make sure teams can work without any
|
Blue bins are your security stock, to make sure teams can work without any
|
||||||
blockers. It's to make sure the next team will always have material to
|
blockers. It's to make sure the next team will always have material to
|
||||||
transform. But it comes with a cost: overburden, stagnation (increase lead
|
transform. But it comes with a cost: overburden, stagnation (increase lead
|
||||||
time) and duplicated mistakes (not simulated here). The less you have, the
|
time) and duplicated mistakes
|
||||||
|
<span class="meaning">not simulated here</span>. The less you have, the
|
||||||
less your team has mental charge. The more you have, the more secure you
|
less your team has mental charge. The more you have, the more secure you
|
||||||
are to make teams work. One solution: simplify your flow and lower the
|
are to make teams work. One solution: simplify your flow and lower the
|
||||||
number of operation the teams have to do to deliver a feature.
|
number of operation the teams have to do to deliver a feature.
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ import {
|
|||||||
getMean,
|
getMean,
|
||||||
pickRandomElement,
|
pickRandomElement,
|
||||||
popNElement,
|
popNElement,
|
||||||
|
randomFloat,
|
||||||
shuffleArray,
|
shuffleArray,
|
||||||
sumElements
|
sumElements
|
||||||
} from '@/utils'
|
} from '@/utils'
|
||||||
@@ -28,7 +29,7 @@ const hasQualityIssue = ({
|
|||||||
)
|
)
|
||||||
|
|
||||||
const multiplicator = getOverburdenMultiplicator(tasksInParallel)
|
const multiplicator = getOverburdenMultiplicator(tasksInParallel)
|
||||||
const quality = Math.random()
|
const quality = randomFloat(0, 1)
|
||||||
|
|
||||||
return quality > qualityProbability / multiplicator
|
return quality > qualityProbability / multiplicator
|
||||||
}
|
}
|
||||||
@@ -230,7 +231,7 @@ export const nextDay = (
|
|||||||
state.meta.teamWorkExperience += 0.01
|
state.meta.teamWorkExperience += 0.01
|
||||||
|
|
||||||
if (strategy === 'problem-solving') {
|
if (strategy === 'problem-solving') {
|
||||||
const hasTeamLearned = Math.random() > 0.25
|
const hasTeamLearned = randomFloat(0, 1) > 0.25
|
||||||
if (hasTeamLearned) {
|
if (hasTeamLearned) {
|
||||||
state.meta.teamWorkExperience += 1.2
|
state.meta.teamWorkExperience += 1.2
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,9 +1,10 @@
|
|||||||
import { birds } from '@/data/bird'
|
import { birds } from '@/data/bird'
|
||||||
import { Feature } from '@/modules/feature/feature'
|
import { Feature } from '@/modules/feature/feature'
|
||||||
|
import { randomInteger } from '@/utils'
|
||||||
|
|
||||||
export const features: Feature[] = birds.map((name) => ({
|
export const features: Feature[] = birds.map((name) => ({
|
||||||
name,
|
name,
|
||||||
complexity: Math.floor(Math.random() * 5) + 1,
|
complexity: randomInteger(1, 5),
|
||||||
leadTime: 0,
|
leadTime: 0,
|
||||||
status: 'doing',
|
status: 'doing',
|
||||||
step: Infinity,
|
step: Infinity,
|
||||||
|
|||||||
16
src/utils.ts
16
src/utils.ts
@@ -1,3 +1,15 @@
|
|||||||
|
import { Random } from 'random-js'
|
||||||
|
|
||||||
|
const random = new Random()
|
||||||
|
|
||||||
|
export const randomInteger = (min: number, max: number) => {
|
||||||
|
return random.integer(min, max)
|
||||||
|
}
|
||||||
|
|
||||||
|
export const randomFloat = (min: number, max: number) => {
|
||||||
|
return random.real(min, max)
|
||||||
|
}
|
||||||
|
|
||||||
export const getMean = (data: number[]) =>
|
export const getMean = (data: number[]) =>
|
||||||
Math.round(100 * (sumElements(data) / data.length)) / 100
|
Math.round(100 * (sumElements(data) / data.length)) / 100
|
||||||
|
|
||||||
@@ -11,7 +23,7 @@ export const shuffleArray = <T>(array: T[]) => {
|
|||||||
randomIndex
|
randomIndex
|
||||||
|
|
||||||
while (currentIndex !== 0) {
|
while (currentIndex !== 0) {
|
||||||
randomIndex = Math.floor(Math.random() * currentIndex)
|
randomIndex = randomInteger(0, currentIndex - 1)
|
||||||
currentIndex--
|
currentIndex--
|
||||||
;[array[currentIndex], array[randomIndex]] = [
|
;[array[currentIndex], array[randomIndex]] = [
|
||||||
array[randomIndex],
|
array[randomIndex],
|
||||||
@@ -37,7 +49,7 @@ export const popNElement = <T>(array: T[], numberOfElements: number) => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export const pickRandomIndex = <T>(array: T[]) =>
|
export const pickRandomIndex = <T>(array: T[]) =>
|
||||||
Math.floor(Math.random() * array.length)
|
randomInteger(0, array.length - 1)
|
||||||
|
|
||||||
export const pickRandomElement = <T>(array: T[]) =>
|
export const pickRandomElement = <T>(array: T[]) =>
|
||||||
array[pickRandomIndex(array)]
|
array[pickRandomIndex(array)]
|
||||||
|
|||||||
Reference in New Issue
Block a user