mirror of
https://github.com/bitburner-official/bitburner-src.git
synced 2025-03-08 11:29:19 +01:00
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:
@ -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);
|
||||
}
|
||||
|
Reference in New Issue
Block a user