Cookie Clicker

Cookie Clicker

Chips Per Second
z  [developer] 28 Apr, 2024 @ 9:29am
Revised Version of Chips Per Second (1.4)
I have now finished my work on Chips Per Second. I have tested it extensively in all environments and situations that I could think of, and it works perfectly in all of them. From my point of view, this new version can be published exactly as is, but that is a decision for Quazillionaire to make.

I have posted the main[pastebin.com] and info[pastebin.com] files in my pastebin; this is just easiest for me right now as it has been way too many years since I have used GitHub. Quazillionaire can get the files from there, as can anyone else who wants to try out this new version. The rest of this post describes the changes in the new version and is primarily directed to Quazillionaire, but it may be of interest to anyone who wants to know what changes I've made to the mod.

The first thing I did was address the phenomenon whereby as the game progresses, CPS will occasionally flash out of existence, only to return a very short time later. As the game continues to progress, these disappearances become longer, until CPS is never seen at all. Depending on one's style of play and the stage of the game, this phenomenon may or may not happen at all.

When it does happen, it is due to the fact that when this mod was designed, it was believed that once the initial trillion cookie limit was reached and the box showing the number of heavenly chips you would receive upon your next ascension appeared, there would be a constant flow of heavenly chips that could be displayed by this mod. Therefore, the mod was designed so that it did not appear until the the box showing the number of heavenly chips you would receive upon your next ascension appeared, which seems like a good behavior. If the number of heavenly chips ever went to zero, this mod assumed that the number of heavenly chips you would receive upon your next ascension was also zero, and its box was no longer displayed

However, the mod's belief about the behavior of heavenly chips per second (which was clearly not intentional) was incorrect; CPS can go to zero at any point in the game where the total earned prestige is high enough. I explained why this happens in my recent posts in the Comments section for this mod, but as Comments tend to scroll of the screen after a while, I'll repeat the explanation here so that it won't be lost. I'll simply quote the text, so that those who have read the original can easily skip it. I'll start at the part that explains why the CPS may go to zero in the middle of the game.

Originally posted by = z:
The reason that zero is the proper result in many cases has to do with the ubiquitous presence of exponential growth throughout Cookie Clicker, combined with the fact that the rate of exponential growth varies greatly depending on what quantities are being examined.

if you look at the Wiki section Calculating Heavenly Chips,[cookieclicker.fandom.com] you see at the line that starts "Heavenly Chips = " that to find out how many heavenly chips you get from a certain number of cookies, you divide the number of cookies by a trillion and then take the cube root of that result. (This is explained slightly differently earlier in the second paragraph of the Wiki page Ascension.[cookieclicker.fandom.com] The cube root function is the killer here, especially as the number of cookies always includes all the cookies you have ever baked, even across ascensions.

What is happening here is that as the total number of heavenly chips rises, a given amount of cookies will produce fewer heavenly chips. This is easily noticeable. At some point, the number of CPS falls below one, and so it is correctly reported as zero. If you have Cookie Monster installed, you can verify this by looking at the bottom of the tooltip that appears when you hover the cursor over the Legacy info.

The fix here was fortunately simple. This mod now displays its results (even if they are zero) any time there will be a nonzero number of heavenly chips gained upon the next ascension. The result of this new condition is that the box containing the number of heavenly chips per second and the box below it containing the number of heavenly chips you would receive upon your next ascension are either always both present or both not present. This seems to have been the original intention, and in practice it looks good (at least to me).

The next change I made was to fix the number of heavenly chips per second; the number being displayed was often incorrect. The problem here is that the original mod based this number on the current cookies per second (also abbreviated CPS). Yet not only does this not include all cookies that are received as income, but it does not include all cookies that contribute to heavenly chips per second. (These two numbers are usually the same; all earned cookies contribute to heavenly chips as long as they produce at least one heavenly chip). For example, cookies per second does not include cookies produced by clicking, cookies produced by the Garden upon harvest of certain plants, cookies produced by the Stock Market, cookies produced by random drops, the one minute of cookie production produced by clicking Reindeer, etc.

Rather than trying to pin down all the different ways cookies can be earned (which is actually impossible, since players can create arbitrary mods that cause various amounts of cookies to be earned), I took the more radical step of rewriting the chip production algorithm for this mod completely and eliminated its dependence on cookies per second, which actually resulted in a simpler algorithm.

Since the game already keeps track of how many new heavenly chips are going to be granted at the next ascension, all I had to do was sample this number every second and subtract the previous sample from the current one. The result is the current number of heavenly chips per second, and it includes everything.

There was one final issue I had to address to make this all work smoothly. The main logic tick in Cookie Clicker goes off twice every second, and that's what's used to control the display of heavenly chips gained upon the next ascension. The original version of this mod uses the same twice per second tick to control its display; the result is that the two adjacent boxes update at the same rate. There's only one problem with this; essentially all of the heavenly chip production that is being counted in the new version of this mod and wasn't being counted before tends to come in short bursts, which is undoubtedly why it isn't counted in the cookies per second calculations. With the new mod as it stood, these short bursts were displayed for half a second - the length of the mod's tick. This made reading their data almost impossible and extremely easy to miss; for many people, that speed did make the data impossible to read.

I addressed this by making the tick rate for this mod one second. Yes, it's now updated only half as often as the data in the box below it, but that shouldn't be a big problem. Having it be updated once per second makes sense when you consider that it's displaying the number of heavenly chips per second. And it makes it a whole lot easier to read the data when it appears.

So that should cover it. Quazillionaire, if you like what you see, go ahead and publish it. Or we can continue this discussion in this thread if you like. (Or both.) As I mentioned earlier, anyone else is free to use this version of the mod in their game by downloading it from my pastebin. And like the original mod, it does not require the Steam version of Cookie Clicker to work, nor does it disable Steam achievements.

For anyone who wants to keep up with any future posts to this discussion, you can easily subscribe to it. There's also a button to subscribe to the forum so that you will be notified any time a new discussion is started.
Last edited by z; 28 Apr, 2024 @ 10:12am
< >
Showing 1-1 of 1 comments
Quazillionaire  [developer] 5 May, 2024 @ 11:13am 
Very cool! I will give this a test sometime soon, and once I verify everything looks good I will update the official version, and credit you as a contributor. Thanks for the deep dive on this, I will let you know when I have a chance to get into it.
< >
Showing 1-1 of 1 comments
Per page: 1530 50