tankorsmash / BuildUpTheBase_bugreports

0 stars 0 forks source link

Coin per second displays as zero #20

Open tankorsmash opened 7 years ago

tankorsmash commented 7 years ago

From @Pyro699 on September 15, 2017 18:28

When you have a lot of coin on hand, eventually the number says that you are getting 0 per second, assuming this is a floating point error. image

Copied from original issue: tankorsmash/BuildUpTheBase#2

tankorsmash commented 7 years ago

This is potentially because the number of total coins is too big that CPUs (or something, I'm not a scientist) can't compare 386 and 32 trailing zeroes and a 1 and 386 and 32 trailing zeros and a 5. Not sure what I can do about this.

Marking as wontfix for now, but I'm leaving it open.

CodyWoolaver commented 7 years ago

Seems like something that should be fixed. The number of coin per second im earning is around 5b/sec... It only disappears when I have a certain amount on hand, if i take that balance and put it all in the bank then the display comes back.

tankorsmash commented 7 years ago

If you open the chrome console, this is basically the source of the problem. It doesn't see you've got a bigger number.

1000000000000000.0 == 1000000000000000.011
>> true

It can compare smaller numbers, but since all the numbers are the type long double I think CPUs literally can't compare accurately. Like I said there's literally 36 zeroes in a decillion so I'm thinking it's a technical impossibility to solve this without a serious overhaul of the backend. That being said there's geniuses out there that have probably solved this problem, or there's a basic solution I can't think of.

CodyWoolaver commented 7 years ago

What language is the core of this - In python you can approach a similar problem and there are specialty libraries made to handle large numbers. https://docs.python.org/2/library/decimal.html

There must be something that can be utilized for this.

tankorsmash commented 7 years ago

I'm using C++ and the game library cocos2dx.

Yeah there has to be a library for sure. I would just not rather have to add that as a dependancy to fix this one problem haha. I think if I tune the numbers so that they're not as big I can side step the whole issue. Plus since phones are slow I need to keep things as lean as possible, and since the game's dealing with 100s if not 1000s of numbers each frame I want to keep it to a basic data type.

Still though, I get where you're coming from. I'll think about this and maybe there's a nicer way to track the coins you've added. Rather than a comparison to last second, each time you get a coin you add it to the tracker, for example. So each second it resets that tracker to 0 and shows the last number.

CodyWoolaver commented 7 years ago

I felt like this could be viewed at as a larger "performance" issue in that case. While I understand that right now it is just for the sake of displaying a value... You might find that using an external library as a standard for all numeric types moving forward can increase performance and the large scale math that you are doing. I am unable to confirm this or not, because i do not see enough significant digits, but you may be losing quite a bit of coin due to rounding issues on the higher values.

tankorsmash commented 7 years ago

Yeah very true about the potential for lost data right now. Most games get around this by taking advantage of being less transparent and more simple, so you don't even realize this is going on.

Also true that there's potentially better ways to speed the game up outside of that if there's that many evals going on per frame. That being said I'm still very happy with the way the game runs already, so I'm just trying to be more mindful of the future implications.

Anyway I'll keep thinking about this.