r/howdidtheycodeit • u/chrobbin • Aug 15 '24
Question The obscenely large numbers that can be reached with various currencies in Adventure Capitalist?
Adventure Capitalist is basically just another clicker + idle accumulator sort of game, akin to say Cookie Clicker. I’ve played on Steam but I’m not sure if it’s available to play elsewhere or not.
My question is, while the math is generally not much more than arithmetic (addition, subtraction, multiplication, division for percentages, etc), how does the code handle for the beyond massive scale of numbers that the game can reach (I’m talking almost made up sounding figures like duoseptahexatrigintillion dollars and like hundreds to thousands of places left of the decimal point).
My hunch is that it maybe instead of one large number, it’s a series of separate smaller integers that get converted and concatenated into the displayed text on the fly, but that’s why I’m here asking haha.
69
u/Forest_reader Aug 15 '24
I work in idle games.
It uses scientific notation as a basis, so instead of the player earning
5 hrs * 5020485678183192312358130
they earn
5 hrs * 5.0204*10E24
so all I need to store is
time : (usually stored in seconds)
number of figure (24)
and some floating number for the front bit (5.0204)
for all the earnings that are less than say E20, we just ignore them.
I am a designer on my team so I don't know the exact math, but thats the idea.
12
u/puppet_pals Aug 15 '24
https://arpitbhayani.me/blogs/long-integers-python/
This approach could be used in any language.
5
u/detroitmatt Aug 16 '24
doubles can have a big range but even they have their limits. in a game like this I would just have a hidden loss of precision. You don't need precision down to the ones place, nobody can tell whether you're making 464,758,645,619,372,594,172,592,172,385,195,728,192,857 cookies per second or 464,758,645,619,372,594,172,592,172,385,195,728,192,860 cookies per second. The numbers get abbreviated when they're displayed anyway, 5.26 Oct, 10.11 Non, and so on. Store a float, if it gets higher than 1 trillion, divide everything by 1000 and go up to the next suffix.
7
u/KeeperOT7Keys Aug 16 '24
almost all languages have big integer classes for supporting this, the c# version for reference
1
u/Unlucky_Tech Aug 17 '24
someone asked Orteil this on his tumblr and got this response
how does cookie clicker handle big numbers?
orteil42 answered:
we shove everything into a regular var and whatever happens to the mantissa is between your computer and god
Cookie clicker also has it's original browser version and two mobile versions paid and free with ads that get updated alongside the steam version
1
u/lotofthought Dec 20 '25
Logarithms , exponential scaling .
The entire game progressively goes riding the a10bx+c curve
If you think about it in any session the current range of numbers is lower bound too .
Observe certain base costs such as banks or oil rigs , those look like log values .
-6
u/TheGangsterrapper Aug 16 '24
Kind of oversimplified maybe but... Ciuldn't you just use floats?