From 8b026f606bfbd498d74443f031d059b16468ced1 Mon Sep 17 00:00:00 2001 From: Undeemiss Date: Sat, 28 May 2022 21:26:11 -0500 Subject: [PATCH] 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. --- src/Bladeburner/Skill.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Bladeburner/Skill.ts b/src/Bladeburner/Skill.ts index 56398ab96..cdf5e03e2 100644 --- a/src/Bladeburner/Skill.ts +++ b/src/Bladeburner/Skill.ts @@ -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); }