Slimmmo / Slimmmo.github.io

AdVenture Capitalist calculator
http://slimmmo.github.io/
35 stars 42 forks source link

Late game Mars calculations error (False Zero Calculation) #108

Open CptHampton opened 8 years ago

CptHampton commented 8 years ago

I've completed everything on Mars and am now just playing through to farm Mega Bucks. If I start with 2500 of everything and all cash/angel upgrades purchased, it seems there is a lower threshold for "Increase in $ / second," where being below that threshold just counts the increase as a flat zero. I understand that certain purchases will have an insignificantly small calculation for the "Upgrade Score" statistic to the point where it never makes sense to buy it, but with the increase statistic being incorrect how can I be sure that those purchases aren't actually useful and the calculator is simply ignoring them?

Slimmmo commented 8 years ago

I think I know what the problem is here but unfortunately it's not a simple fix.

Javsacript has a maximum value of 1.7976931348623157e+308, which isn't that high for this game so once you start getting into the late late late game you start hitting this number and Javascript takes it as Infinity. Anything divided by Infinity is 0 and Infinity divided by anything is Infinity so the calculator loses all usefulness at this point.

I'm open to hearing possible solutions from anyone.

skupr commented 8 years ago

There are some JS large numbers libraries, like https://github.com/MikeMcl/big.js/ The main issue that JS has no operator overloading. Because of that fact, these libraries have additional methods for each math operations. So switching to such library would require to rewrite many math-related code, which I believe is a HUGE task.

skupr commented 8 years ago

Probably, some trick may be implemented - when we detect input values that overflow JS Number, it is scaled down, and all the math is performed with scaled down values, then when we display value, it is scaled up back again. But it seems to me very hard to implement because not all calculations will allow this, and such change requires careful revising of each formula/condition for possible scaling problems.