Skip to content

Commit 4e8ea23

Browse files
committed
Move out va2 compute from tick function;
1 parent c983428 commit 4e8ea23

1 file changed

Lines changed: 9 additions & 4 deletions

File tree

src/Theories/CTs/MF.ts

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,7 @@ class mfSim extends theoryClass<theory> {
7272
precomp_vexp: number;
7373
precomp_a1exp: number;
7474
precomp_vterm: number;
75+
precomp_va2: number;
7576

7677
bestRes: simResult | null;
7778

@@ -309,6 +310,7 @@ class mfSim extends theoryClass<theory> {
309310
this.precomp_omegaexp = -1;
310311
this.precomp_a1exp = -1;
311312
this.precomp_vterm = -1;
313+
this.precomp_va2 = 10 ** this.variables[3].value;
312314
this.updateMilestonesNoMS();
313315
// This will update precomp_vterm:
314316
this.precomputeExps();
@@ -340,6 +342,7 @@ class mfSim extends theoryClass<theory> {
340342
this.stopReset = other.stopReset;
341343
this.goalBundle = [...other.goalBundle];
342344
this.goalBundleCost = other.goalBundleCost;
345+
this.precomp_va2 = other.precomp_va2;
343346
this.precomputeExps();
344347
}
345348
copy(): mfSim {
@@ -380,21 +383,23 @@ class mfSim extends theoryClass<theory> {
380383
return getBestResult(result, this.bestRes);
381384
}
382385
onVariablePurchased(id: number) {
386+
if(id === 3) {
387+
this.precomp_va2 = 10 ** this.variables[3].value;
388+
}
383389
if(this.mfResetDepth === 0 && this.isCoast && id === 0 && this.lastC1 === Infinity && (this.maxRho > this.lastPub + 6)) {
384390
this.forkOnC1 = true;
385391
}
386392
}
387393

388394
tick() {
389395
// Deal with i
390-
const va2 = 10 ** this.variables[3].value; // a2, non-log10 value
391-
let icap = va2*i0; //max reachable i value
396+
let icap = this.precomp_va2 * i0; //max reachable i value
392397

393398
if(this.i < icap) {
394399
// if max i is not reached, we add a value to it:
395400
const va1 = 10 ** (this.variables[2].value * this.precomp_a1exp);
396-
let scale = 1 - Math.E ** (-this.dt*va1/(400*va2));
397-
if (scale < 1e-13) scale = this.dt*va1/(400*va2);
401+
let scale = 1 - Math.E ** (-this.dt*va1/(400*this.precomp_va2));
402+
if (scale < 1e-13) scale = this.dt*va1/(400*this.precomp_va2);
398403
this.i = this.i + scale*(icap - this.i)
399404
this.i = Math.min(this.i, icap);
400405
}

0 commit comments

Comments
 (0)