-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Description
A bugfix in break_eternity.js (Patashu/break_eternity.js@8b6efe7) for Patashu/break_eternity.js#43 is causing a few instances of NaNs in my post-game save when cherry-picked into Prestige Tree Rewritten:
-
ba12 softcap:
Lines 273 to 280 in cec9198
ba12: { title: "Top-Right Balance Upgrade (Positive Ion)", type: "log", start: new Decimal(0.75), exp: new Decimal(0.25), display() { return hasUpgrade("ba", 12) && upgradeEffect("ba", 12).gte(this.start) }, info() { return "Starts at "+format(this.start.times(100))+"%, logarithmic and brought to the "+format(this.exp.pow(-1))+"th root" }, },
is causing errors here:
Lines 386 to 387 in cec9198
let exp = getSoftcapData(name, "exp"); return val.log10().pow(exp).times(start.div(start.log10().pow(exp)));
specifically this portion:start.log10().pow(exp)
start.log10()is -0.12493873660829993, so this calculates (-0.12493873660829993 ^ 0.25), causing a NaN. This has no real roots. -
nextMinibot:
Lines 8271 to 8274 in cec9198
nextMinibot() { if (player.r.allotted.breeders.lt(1)||tmp.r.totalMinibots.gte(tmp.r.minibotCap.plus(player.r.spentMinibots))) return new Decimal(1/0); else return Decimal.pow(10, tmp.r.totalMinibots.sub(player.r.grownMinibots.times(tmp.r.reduceMinibotReqMult)).plus(1).pow(1.5)).times(1e5).div(player.r.allotted.breeders.max(1).pow(tmp.r.breederExp)); },
specifically, this portion:tmp.r.totalMinibots.sub(player.r.grownMinibots.times(tmp.r.reduceMinibotReqMult)).plus(1).pow(1.5)
At one point in time:
tmp.r.totalMinibots = 1player.r.grownMinibots = 627tmp.r.reduceMinibotReqMult = 1
so this calculates (-625 ^ 1.5), causing a NaN. This has no real roots.
-
The Brain "next":
Line 7874 in cec9198
next() { return Decimal.pow(10, Decimal.pow(10, new Decimal((player.ne.activeChallenge==11||hasAchievement("a", 151))?tmp.ne.challenges[11].amt:0).plus(1).div(tmp.ne.challenges[11].gainMult).root(tmp.ne.buyables[11].effect).log10().root(3).times(11)).sub(1)).sub(1) }, That's a lot of code. Formatted using prettier, it looks like:
Decimal.pow( 10, Decimal.pow( 10, new Decimal( player.ne.activeChallenge == 11 || hasAchievement("a", 151) ? tmp.ne.challenges[11].amt : 0 ) .plus(1) .div(tmp.ne.challenges[11].gainMult) .root(tmp.ne.buyables[11].effect) .log10() .root(3) .times(11) ).sub(1) ).sub(1);
and the problem is in the
.root(3)after the.log10, which ends up calculating (-2.6340821214933543 ^ (1/3)). This technically does have a real root of -1.3810511702377193, as (-x)^(1/3) = -(x^(1/3)). -
Wraith buyMax (spotted while going into The Brain in an end-game save):
Lines 5003 to 5006 in cec9198
buyMax() { let target = player.ps.points.sub(1).div(2).min(player.ps.souls.sub(200).div(174).root(4).sub(1)).times(tmp.ps.buyables[this.id].scaleSlow).plus(1).floor().max(0) player[this.layer].buyables[this.id] = player[this.layer].buyables[this.id].max(target) },
specifically this portion:player.ps.souls.sub(200).div(174).root(4).sub(1)
player.ps.soulsis zero, so this calculates (-1.1494252873563218 ^ (1/4)). This has no real roots.
There might be more instances that surface if you're not at end-game.
The easiest way of resolving this problem is to call .abs() before calling .root or .pow, as that should keep the behaviour identical to the currently used version of break_eternity.js if break_eternity.js is updated (and is a no-op if break_eternity.js isn't updated). However, in some cases a .max call might be more appropriate.