Fixed off-by-one error in the fast calculateCost function

The off-by-one error was in the original sum, so it's not obvious
in the simplified version of the sum. Fixing this greatly improved
the accuracy of the simple calculation for small counts, but I'm
leaving the recursive mode in. Maybe I'll lower the threshold,
though. 100 isn't a terribly small number.
This commit is contained in:
Undeemiss 2022-05-28 21:26:11 -05:00
parent 8d9e077b66
commit 8b026f606b

@ -148,7 +148,7 @@ export class Skill {
//unFloored is roughly equivalent to
//(this.baseCost + currentLevel * this.costInc) * BitNodeMultipliers.BladeburnerSkillCost
//being repeated for increasing currentLevel
const preMult = (count + 1) * ((2 * this.baseCost) + this.costInc * (2 * currentLevel + count)) / 2;
const preMult = count * ((2 * this.baseCost) + this.costInc * (2 * currentLevel + count + 1)) / 2;
const unFloored = (preMult * BitNodeMultipliers.BladeburnerSkillCost) - count / 2;
return Math.floor(unFloored);
}