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, which I will call $$T$$. 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.

Treasures that give fixed Energy or revive
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 $$TE = 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 horizontal (x) axis shows the distance run here (which for now we can say is the same as time), and the vertical (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, or in math terms: $$BEABU + 180 = BEABU + 3 \cdot (3 \cdot 20)$$. A relationship of type $$y = ax + b$$ is called a linear relationship because, if we plot it on a graph, we will get a line and not a curve or something else. Adding more revives or Energy per revive means that we get a steeper line, but it's still a line nonetheless.

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.

To find out the total run time $$T$$ for a treasure of a treasure that adds extra energy or revives is easy. If we have say, 100 Energy to begin with and we lose Energy at a rate of 1 per second, then naturally we will get a run length of 100 seconds, i.e. T will be 100. If we lose 2 energy per second, we only run for half the time, i.e. 50 seconds and so on. So, to get $$T$$ here, we just have divide $$TE$$ by the amount of Energy we lose per second, which i will call Energy Drain per Second, or $$EDS$$. We get

$$T = \frac{TE}{EDS}$$

A EDT is 3 Energy/second for episode 1, 4 for episodes 2 and 4 and 5 for episode 3.

Slower Energy Drain
The time between ticks that we lose Energy normally is one second. But with treasures that give a Slower Energy Drain (SED), that time is longer. This means that without any other factors considered, having 10% SED means we can run for 10% longer, right? But what about if we have two 10% SED treasures instead? Does this mean we run for 20% longer?

Well, not really. Let's think about what SED really means. The normal time between two ticks is 1.00 seconds. A 10% SED means we take the tick time and add 10% of itself, i.e. $$1 + 1\cdot 0.1$$, so we now get 1.1 seconds between ticks instead. If we have two treasures with SED, we have to add 10% of the current tick time, which is 1.1, and add 10% to that, and not simply adding 20% to 1. If we do it this way, we get $$(1 + 1 \cdot 0.1)\cdot (1 + 1 \cdot 0.1) = 1.1 \cdot 1.1 = 1.21$$. If we have a third treasure, we get $$1.1 \cdot 1.1 \cdot 1.1 = 1.331$$, and so on.

What the values like 1.1, 1.21 and 1.3 above tells us is that we get a 1.1, 1.21 or 1.3 times longer run time, or $$T$$ with 1, 2 or 3 treasures equipped. In other words, if $$T_O$$ is our old value for T and we equip $$n$$ treasures with 10% SED, the new total run time $$T_N$$ is

$$T_N = T_O \cdot 1.1^n$$

Because we have a function with a power inside, $$a^n$$ instead of something that grows linearly like $$y = ax+b$$, we get a much "growth rate" of $$T$$ for treasures with SED is higher than for having treasures with fixed Energy. How much higher? We can compare them in the graph below. Because run time with SED is expressed as a percentage based off the previous treasures, we will get a curve rather than a line when looking at the graphs for these kinds of treasures.



This graph shows that at a BEABU of 445, having 3 Foxy Bead's Hearts is better than 3 treasures that give SED at 10%. But for 20% it's almost always better to have SED, even compared to a treasure that gives 90 Extra Energy! And, if we could have 8 treasures, then even 10% is better than 8 Foxy Bead's Hearts!

And what does $$T_O$$ depend on? Well, it depends on the BEABU and EDT. We can't change the EDT, but we can increase the BEABU. So for higher values of BEABU, we can get higher values of T compared to fixed-value treasures, even for low percentage SED:s.

Let's look at the same graph but for a BEABU of 1000.



Wow! Even with only one treasure equipped, having one 10% SED treasure beats both fixed 60 AND 90 extra Energy treasures.

Comparing values of T
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 } = \frac{BEABU}{\frac{EDT}{(1+SED)}} = \frac{(SED+1)\cdot BEABU}{EDT}$$

where once again,
 * $$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 or using relays, 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, simply add the extra energy to the BEABU in the second formula above.

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{(1+0.1)\cdot (445+40)}{3} \approx 178$$

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

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

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. When having 2 treasures of the same kind, that means multiplying SED with itself, or taking $$SED^2$$. For 3 treasures of the same kind, we get $$SED^3$$.

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

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

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

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

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

But let's see what happens when we increase the BEABU, which is the case when we include potions, relays etc. Let's try a higher BEABU of 2000, an extreme run with lots of potions and relays included:

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

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

so now the cocktails are starting to take off! In real runs so far however, the BEABU is likely to be somewhere around 1000, so for now the Muffins are still the winner. But suppose we get cookies with more Energy in the future, more health upgrades and stages with more Potions. Then, having Cocktails or any treasure with higher SED would guarantee a better outcome.

Finding the cutoff point
So we saw in the second section that the usefulness of SED vs fixed-energy treasures is starting to appear after a certain point. But at what point? Once again we have the formula for getting $$T$$ from fixed-health treasures:

$$T_A = \frac{BEABU + E}{EDT}$$

and ones where we're getting SED

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

We want to know when $$T_B > T_A$$, i.e. when is

$$\frac{(SED+1)\cdot BEABU}{EDT} > \frac{BEABU + E}{EDT}$$

But this equation has 4 unknowns. This means that if we would plot this on a graph to find a solution, we would need 4D space. We could eliminate the EDT variable however, since it's fixed in both cases. That means that if we would plot graphs with this inequality we will get a 2D plane solution in 3D space, which still hurts my mind to think of... Mathematically, what we get is a solution that looks like this:

$$0 < E < BEABU \cdot SED$$

If it's confusing, the simply plug in some values and see for your particular case what the cutoff point would be. For example, with a BEABU of 1000, E needs to be less than 1000 times SED in percent. For example, treasure with 50 extra fixed energy would be as good as a treasure with 5% SED, since $$ 1000\cdot 0.05 = 50$$. A 6% SED would definitely be better, but just as good as a 60 extra fixed energy treasure and so on.

Of course, we don't actually know our BEABU with potions and relays involved, so this is why it's so hard to create a model of how our run is going to be mathematically. This formula should give you a rough idea of what we're dealing with.

We could however, if we want to find the cutoff point for when SED becomes better than a foxed extra Energy. In this case we let BEABU be the unknown in our equation and plug in values for the rest. Tricoro gave me a good example for this in the comments - suppose we run with 3 cocktails vs 3 muffins and both have a 25% SED random boost. We thus want to find for what values of BEABU the inequality

$$(1.1)^3 \cdot 1.25 \cdot (BEABU + 120) > (1.07)^3 \cdot 1.25 \cdot (BEABU + 270)$$

After simplification, we get $$BEABU > 1614.25$$. This is a huge value for BEABU and is not feasible in a run unless we have a pet that can generate a lot of potions for us.

Extra Energy from Potions
As a side note, I will briefly discuss treasures that give extra energy from potions. And since we have a percentage here, we will again see a non-linear relationship when we add multiple treasures or boosts of the same kind. The usefulness of treasures or pets that give extra energy from potions are also dependent on which episode you play on, as each episode has a different number of potions, and because of the different amounts of energy lost per tick.

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_E$$, is given by:

$$T_E = \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.

The formula should make sense for most people, but let me know if I need to explain how I got it.

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_E = \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_E = \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_E = \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_E = \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_E = \frac{(10 \cdot 30 \cdot (1+0.2)^3) + (30 \cdot 25 \cdot (1+0.2)^3)}{3} = 604$$

If you are running with these types of treasures or boosts, we can get the expected total run time like so:

$$T = \frac{TE}{EDT} + T_E$$

That is, we have simply added the normal expected run time to the extra run time we got from these potion-enhancing treasures.

Conclusion
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 and boosts in the game, with higher percentages of SED or more energy received from potions, they will get the upper hand. And this will be the case for advanced players, as they are able to grab many potions during the run.

Mathematically so to speak, having many treasures with a higher SED will be better than those giving a higher fixed energy, such as in the cocktail vs muffin case. But since the SED difference is only 3%, it will take a high BEABU or a high number of treasure before the cocktail can 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.