-
Notifications
You must be signed in to change notification settings - Fork 270
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
API: Add tests for resolving issues with 'calculateCost' on dev (targeted 2.6.3) #1724
base: dev
Are you sure you want to change the base?
API: Add tests for resolving issues with 'calculateCost' on dev (targeted 2.6.3) #1724
Conversation
…eCount returns 1 when SP is too small and current level is too high
Can you change the title to something indicating that this PR adds tests for |
@@ -14,6 +15,18 @@ const skill = new Skill({ | |||
}); | |||
|
|||
describe("Test calculateMaxUpgradeCount", function () { | |||
it.failing("Bug: Returns 1 when SP is too small and current level is too high", () => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please name these with the expected value of how they should work, not the current buggy state. That way when they are fixed they can just be flipped to it(
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You know I'm not actually sure what the correct behavior is (at least the one's we wish to fix according to the discussion in the issue).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you don't know what the correct behavior is, then it's probably not the right time to be writing tests. XD
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't know how to write the test you suggested (the inverse case). The test I wrote covers the bug, not the fix.
Edit: I can naively claim that return value should be 1, though I do not know how to verify whether that is doable with the current formula.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think you misunderstood what I was asking for. You don't need to be able to fix the bug, or even write a fully fleshed out "regular" test in a situation like this. However, you ought to be able to at least describe in words, for the test description, how the code "ought" to behave, if you think it actually has a bug. Even just inverting what you have ("Should not return 1 at high levels with small SP") would be sufficient, and explains the construction of your test.
Update: I managed to capture the bug better and narrow it to an MRE with regards to cost. |
@d0sboots @catloversg Requesting advice. I'm close, here's my context dump:
Here's my breakdown, hopefully I got the severity right. Let me know:
Possibly an issue
Nice to have (for int farmers)
I should mention that prior to this release (in 2.6.2), the getSkillUpgradeCost returning an actual number made it easier to do a binary search prior to discovering the BB formulas. |
As requested, I'll copy my response in Discord to here. Int farming
/** @param {NS} ns */
export async function main(ns) {
Player.bladeburner.skillPoints = 1e300;
Player.bladeburner.skills["Hyperdrive"] = 1e100;
const before = ns.bladeburner.getSkillLevel("Hyperdrive");
console.log(`Current level: ${before}`);
console.log(`Required SP: ${ns.bladeburner.getSkillUpgradeCost("Hyperdrive")}`);
ns.bladeburner.upgradeSkill("Hyperdrive");
const after = ns.bladeburner.getSkillLevel("Hyperdrive");
console.log(`Current level: ${after}`);
if (before === after) {
console.log("No change");
}
} In the example above, I agree that "returning 0" is not ideal, but at least it indicates that something went wrong. I'll clarify this behavior and mention the new formula API in the TSDoc. If the player wants to implement their "binary search", they can still do that. Maybe they have to change it, though.
That error message is correct. It explained exactly what happened. With BB terminal, the player can only upgrade a skill by 1 level. When "+1 level" is not enough to "overcome" the floating-point inaccuracy, this error message is shown. For all other UI things, it's out-of-scope. |
Also per long discord discussion, copied (but not verbatim) here:
|
Perfect! I'll be traveling starting this week so will pick up hopefully end of november. |
Have fun! We know I am not super speedy anyway XD |
Linked issues
tests #1693
Bug fix
Reported by catlover as we expanded the cap on Bladeburner skills to up to Number.MAX_VALUE.
This draft PR provides coverage for the formulas responses that seem faulty. This is currently in dev and hasn't been released to 2.6.3 yet.