DRY code
parent
5f6e26cdb0
commit
62d72ef80f
|
|
@ -2,12 +2,18 @@
|
||||||
export default {
|
export default {
|
||||||
config: () => {
|
config: () => {
|
||||||
return {
|
return {
|
||||||
variance: Math.random() * 10,
|
...genBaseStats()
|
||||||
base: Math.random() * 10
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function genBaseStats() {
|
||||||
|
return {
|
||||||
|
variance: Math.random() * 10,
|
||||||
|
base: Math.random() * 10
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
function randomNormal(width: number = 1, offset: number = 0) {
|
function randomNormal(width: number = 1, offset: number = 0) {
|
||||||
var u = 0, v = 0;
|
var u = 0, v = 0;
|
||||||
while(u === 0) u = Math.random(); //Converting [0,1) to (0,1)
|
while(u === 0) u = Math.random(); //Converting [0,1) to (0,1)
|
||||||
|
|
@ -22,8 +28,10 @@ export function pull() {
|
||||||
|
|
||||||
export function getAverageReward() {
|
export function getAverageReward() {
|
||||||
const avg = this.config.base;
|
const avg = this.config.base;
|
||||||
this.config.variance = Math.random() * 10;
|
this.config = {
|
||||||
this.config.base = Math.random() * 10;
|
...this.config,
|
||||||
|
...genBaseStats()
|
||||||
|
}
|
||||||
console.log('slots real reward was: ' + avg);
|
console.log('slots real reward was: ' + avg);
|
||||||
return avg;
|
return avg;
|
||||||
}
|
}
|
||||||
Loading…
Reference in New Issue