User blog:Pgrobban/Slower energy drain or extra energy/revives/potions? An explanation for non-geeks

The purpose of this post is to give a brief comparison between setups that give slower Energy drain and those that give extra Energy (in the form of potions, revives or simply extra Energy to the Cookie). I wrote this in a forum post before, but that post became a mess with lots of edits, so I'm trying again here. There is a lot of math involved in what is the optimal run. For this case we are interested in the longest total run time. I will try to keep this as simple as possible so those of you who don't like math can hopefully still follow along. For the sake of simplicity, I will consider a perfect run without collisions.

So we start off with a Cookie that has a certain amount of energy. Let's say we use a level 8 Moonlight Cookie which has 185 Energy. Together with the Energy Boost upgrades, we can currently get her health to a maximum of 445 Energy (185 + 260 from lv. 60 boost upgrade). Easy so far, right? Let's call this number the Base Energy After Boost Upgrades, or BEABU.

First we look at ways of adding even more energy through treasures to get the amount of Total Energy (TE). For now we assume that we can just add one treasure. Example: Foxy Bead's Heart at level +9 with our previous example gives a total of 445 + 60 = 505 energy. Example: +9 Heavenly Sweet Donut revives 3 times with 20 energy, so we add $$3 \cdot 20$$. With our previous example, it becomes $$445 + 3 \cdot 20 = 505$$ energy.
 * If the treasure just gives more energy, without doing anything else, we just add the number from the treasure to BEABU, in other words $$TE = BEABU + \text{Energy from treasure}$$.
 * If the treasure revives x times with y Energy, then we add $$x \cdot y$$ to BEABU: $$TE = BEABU + (x\cdot y)$$

Notice that these two treasures gave the same total energy. A treasure that revives 3 times with 20 energy is basically the same as another treasure giving 60 energy directly. The only difference is that we will run out of energy first, then revive and so on, but we will have run the same amount of time and distance, once again provided that nothing else has changed.

So in a run that makes us lose 1 Energy per second, we will take 505 seconds to complete both runs. Here's a graph of how a run might look like with these two treasures side-by-side Energy-wise if we don't add any extra potions to the stages.



The x axis shows distance (or time), and y axis shows remaining energy. We can see that the last time we reach 0 energy for the donut case is the same time as we reached 0 for the Foxy Bead's Heart case.

So no matter if we use a treasure that gives 60 extra Energy, or another treasure that gives 3 times 20 extra Energy, or just increase the BEABU with 60 directly, we will get the same result in total energy. TE scales linearly with these types of treasures. We can see this with the graph below (although this should be obvious).



If we have 3 Foxy Bead's Hearts, it's basically the same as adding 180 Energy directly to our BEABU. Same with reviving treasures: 3 treasures of something reviving 3 times with 20 Energy is the same as adding 180 Energy directly. These types of treasures form a linear relationship with the total amount of energy, and thus also with the time it takes to complete the run.

If we think about adding Potions to the table, it works in the same way. They're just a constant that is added to the BEABU. So if we get 8 Potions worth 25 Energy each, it's just the same as adding 200 to the BEABU directly, in both cases we get a TE of 645, right? However, this is not the same as adding a "more energy from potions bonus", see below.

Slower Energy Drain
When Slower Energy Drain (SED) comes into play, things get more tricky. SED does not grow linearly when adding multiple treasures of the same type. Let's look at a graph to show their differences for a BEABU of 445.



At first it might seem that the better choice is a treasure that gives a fixed amount of energy, but once we add more treasures of the same type, SED comes out as a clear winner. Why is this? It's because SED does not grow linearly. Once you start scaling things, by changing the SED percentage or the number of treasures involved, the graphs for SED show that they take off at much higher speeds than those adding fixed energy.

The base formula we use to get the time $$T$$ it would take to end the run is given by $$T = \frac{TE}{\text{Energy loss per second}}$$. If we have a TE of 500 and lose 1 energy/second, then it's natural to think that it would take 500 seconds to lose all Energy, right? If we lose 2 energy/second, then $$T = \frac{500}{2} = 250$$, i.e. we'd only run for 250 seconds and so on.

Now, if we have a SED it's basically the same as saying we lower the energy loss per second. A 10% slower Energy drain means that we lose energy after 1 second + 10%, i.e. after 1.1 seconds. So we have the seconds to lose one Energy, but according to the formula, we want to get the "opposite", which is how much Energy we lose per second, and not how many seconds it takes to lose 1 Energy. So we take the reciprocal of this number, i.e. $$\frac{1}{1.1} \approx 0.90909...$$.

So with a TE of 500 and a 10% slower Energy drain we get a total running time of $$T = \frac{500}{(\frac{1}{1.1})} = 550$$. But watch what happens when we add one more treasure of the same type.

First we take the normal loss of 1 energy per second. Then we add the 10% SED from the first treasure, giving us a loss of energy after 1.1 seconds. But now, when we have another 10% SED, we have to consider that the current time of losing one energy is 1.1 seconds, so this is the number we have to add 10% to, in other words: 1 + 10% + 10%, or $$1 \cdot 1.1 \cdot 1.1 = 1.21$$ and not 1.2 which one might think from adding Energies like we did from the first types of treasures or adding potions. To see how much energy we lose per second, we take the reciprocal of the above value: $$\frac{1}{1 \cdot 1.1 \cdot 1.1} = \frac{1}{1 \cdot 1.1^2}\approx 0.82644$$. So if we started out with a TE of 500, with 10% + 10% SED, we can now expect to run for $$\frac{500}{\frac{1}{1.1^2}} = 605$$ and not 600 seconds as you'd might think.

We can simplify the calculations a bit. Instead of $$\frac{x}{(\frac{1}{y})}$$ we can say that this is the same as $$x \cdot y$$, but that's not important. The important thing is, notice that in our calculations, y multiplies when we add more than one treasure that gives a SED. If we have two treasures with the same SED percentage, then we get $$y^2$$, if we have 3 then we get $$y^3$$. The power function $$a^x$$ grows much faster than a linear function $$y = ax + b$$, such as when we added energy from revives.

Let's say you have two treasures, one that gives 60 extra Energy and one that gives 10% slower Energy drain. The 10% SED might seem worse at first since you only get 550 Energy vs 560 from the first one, but remember that we add this bonus to all of the potions you will get extra Energy from potions as well, and those will give you a longer time of running after all. At a BEABU of 1000, the SED will give you 100 extra seconds of running time whereas adding the treasure of the first kind will still only give you 60. And consider that in real runs, we have an energy drain of 3-5 energy per "tick". So 60 extra energy will only give you 12-20 extra seconds of gameplay, while SED will give more.

Comparing values of T
As we are going for the highest values of T possible, Math-wise the difficult thing is finding the cutoff point for when one is better than the other, a fixed amount of energy vs SED. If we start with a low BEABU, it's always better to add treasures of the first kind, those that give a fixed amount of energy. But above a certain treshold, depending on your BEABU and the SED percentage, SED will come out as a winner.

If you have two treasures that you want to compare, treasure A giving extra energy in some way and treasure B giving SED, compare them like this:

$$T_A = \frac{TE}{EDT}$$

vs

$$T_B = \frac{BEABU}{\frac{1}{(1+SED)}\cdot EDT }$$

where
 * $$TE$$ is the total Energy (BEABU + energy gained from treasure A)
 * $$SED$$ is the slower energy drain. Remember to divide the number in percent by 100, i.e. 12% = 0.12 in the formula.
 * $$EDT$$ is energy drain/tick. The value is 3 for episode 1, 4 for episode 2 and 4 and 5 for episode 3.

If $$T_A > T_B$$ then pick treasure A, otherwise pick B. But once again, this doesn't say anything about potions that we pick up during the run, so the formula is biased towards treasures with fixed Energy while in real runs, this won't be the best option.

If a treasure gives extra Energy and slower Energy drain, we do:

$$T = \frac{TE}{(\frac{1}{1+SED})EDT}$$.

Example: 
 * Moonlight Cookie at Lv. 8 = 185 energy
 * Lv. 60 Energy Boost upgrade
 * gives us BEABU = 185 + 260 = 445 energy
 * Running at episode 1 means EDT = 3

Case 1: Specially made Flaming Cocktail at lv.9 gives 10% slower Energy drain and one revive with 40 Energy.

$$T = \frac{445 + 40}{(\frac{1}{1+0.1}) \cdot 3} \approx 178$$

Case 2: Supremely Yummy Monster Muffin gives 7% slower Energy drain and one revive with 90 Energy:

$$T = \frac{445 + 90}{(\frac{1}{1+0.07}) \cdot 3} \approx 190$$

so in this case the Muffin wins.

Consider also the cases of where we have multiple treasures of the same type. For the first type, the ones that give a fixed Energy increase, we simply add those numbers together for our E value in the formula. For SED treasures, we multiply those values for the SED value in the formula.

For the cocktails we get: $$T = \frac{445 + 40 \cdot 3}{(\frac{1}{1.1^3})\cdot 3} \approx 251 $$ seconds.

For the muffins we get $$T = \frac{445 + 90 \cdot 3}{(\frac{1}{1.07^3})\cdot 3} \approx 291$$ seconds.

And now let's consider adding a 25% Slower Energy random boost:

For the cocktails we get: $$T = \frac{445 + 40 \cdot 3}{(\frac{1}{1.1^3 \cdot 1.25})\cdot 3} \approx 313 $$ seconds.

For the muffins we get $$T = \frac{445 + 90 \cdot 3}{(\frac{1}{1.07^3 \cdot 1.25})\cdot 3} \approx 364$$ seconds.

It might seem thus that the Muffins win by a large margin, but remember, once we get a higher BEABU, that margin will decrease, and become even smaller when potions come into play. It's quite possible that some of my calculations have careless mistakes in them or that the formulae are wrong altogether, but this is the best model I could come up with for a basic comparison.

Extra Energy from Potions
The usefulness of treasures or pets that give extra energy from potions are dependent on which episode you play on, as each episode has a different number of potions. It's really hard to make an accurate model of a run's length considering extra potions, but we can look at how much extra time we get from potions on their own. The total extra time, which I will call, T, is given by:

$$T = \frac{n \cdot BPE \cdot (1+EI)}{EDT}$$ where


 * $$n$$ is the number of Potions in the stage
 * $$BPE$$ is the base energy for a potion (30 for giant potion)
 * $$EI$$ is Energy increase in percent, i.e. 25% more energy would be 0.25 in the formula
 * $$EDT$$ is the amount of Energy we lose per tick, i.e. 3 for episode 1, 4 for episodes 2 and 4 and 5 for episode 3.

So let's say we're running in episode 1, which has 10 giant potions, with a treasure that gives 20% extra Energy. The extra time we get from potions is thus

$$T = \frac{10 \cdot 30 \cdot (1+0.2)}{3} = 120$$

But consider that we didn't use this treasure and just got the base energy for a potion:

$$T = \frac{10 \cdot 30 \cdot 1}{3} = 100$$

only a 20 second increase. The graph confirms that the gap isn't so big in terms of the total amount of Energy gained for a few potions with only one treasure of this kind, but the gap widens quickly as we collect more and more potions. And if we add more than one potion-enchancing treasure, we will get even better results. We see that we once again have a non-linear curve describing the relationship between the number of treasures and the total amount of energy, for a fixed number of potions.





Suppose we have a pet that can make potions for us, with an average of 25 per potion, and we run so far that we got 30 of them:

$$T = \frac{(10 \cdot 30 \cdot (1+0.2)) + (30 \cdot 25 \cdot (1+0.2))}{3} = 420$$

vs if we didn't have the treasure bonus:

$$T = \frac{(10 \cdot 30 \cdot 1) + (30 \cdot 25 \cdot 1)}{3} = 350$$

which is, a more impressive 70 second difference. And the gap becomes even bigger when you consider that these percentages are multiplicative, just like SED. If we had 3 treasures with the 20% boost, we'd get

$$T = \frac{(10 \cdot 30 \cdot (1+0.2)^3) + (30 \cdot 25 \cdot (1+0.2)^3)}{3} = 604$$

So in conclusion, these are the formulas that you can play around with. We can just mathematically say that for low values of BEABU, treasures with a fixed increase of Energy will give a longer run, but once we climb higher with more treasures in the game, with higher percentages of SED or more energy received from potions, they will get the upper hand.

Sorry for the wall of text, but I tried to explain this as simple as I could. If anything is unclear, I'll be happy to explain further.