The Math of Idle Games, Part II

A few weeks ago, in Part I of this three-part series, we looked at some of the standard math behind rapid-growth idle games, primarily at the relationships between exponential and polynomial growth and some methods of checking and adjusting the balance of the various generators over time.

In Part II we’re going to explore a different option for growth outside of the Cookie Clicker model that the vast majority of idle games use these days.

In the "standard" model, there is a primary $\color{ForestGreen}{currency}$ and a bunch of generators ($\color{Cerulean}{Gen 1}$, $\color{BurntOrange}{Gen 2}$, etc.) that produce that $\color{ForestGreen}{currency}$. In AdVenture Capitalist these are the investments generating cash. In Clicker Heroes these are the heroes generating damage, which is then converted into gold.

But who says that generators have to produce primary $\color{ForestGreen}{currency}$? What happens if generators generate other generators, like this?

You have a single generator producing the $\color{ForestGreen}{currency}$ and then a cascading chain of generators producing the previous tier. So $\color{Cerulean}{Gen 1}$ is the rate at which $\color{ForestGreen}{currency}$ is generated. $\color{BurntOrange}{Gen 2}$ is the rate at which $\color{Cerulean}{Gen 1}$ is generated, and so on. Anyone else getting twitchy calculus flashbacks? Good, because you should: these are derivatives! (Note: if you don’t know or remember calculus, don’t worry -- you’re about to learn some!)

Let’s say for a second that a single generator ($\color{Cerulean}{Gen 1}$) produces one $\color{ForestGreen}{currency}$ (the y-axis, representing total $\color{ForestGreen}{currency}$) each second (the x-axis, representing total time). We’ll graph cash in green (obvi!) and you’ll see the single $\color{Cerulean}{Gen 1}$ generator in blue. So over time the number of $\color{Cerulean}{Gen 1}$s doesn’t change, and each second we gain 1 $\color{ForestGreen}{currency}$.

Now let’s say we have a single $\color{BurntOrange}{Gen 2}$ that produces $\color{Cerulean}{Gen 1}$s at 1 per second. What does our graph look like now?

First we need to clarify one oddity of looking at continuous graphs for a discrete problem like this. A $\color{Cerulean}{Gen 1}$ will produce exactly 1 $\color{ForestGreen}{currency}$ in a second. But what if that $\color{Cerulean}{Gen 1}$ is being produced that same second? It won’t generate a full $\color{ForestGreen}{currency}$ point but instead only half of one. You can think of it like $\color{Cerulean}{Gen 1}$ only half-existing in the second it is created, but even if it doesn’t make total sense, if you can accept that rule then everything else lines up in that beautiful way that math always does. With that out of the way, let’s look at the magic.

At time $t$=0, we have a single $\color{BurntOrange}{Gen 2}$ that will never change, no $\color{Cerulean}{Gen 1}$s, and no $\color{ForestGreen}{currency}$.

$t$=1, still a single $\color{BurntOrange}{Gen 2}$, now a single $\color{Cerulean}{Gen 1}$ (produced by the $\color{BurntOrange}{Gen 2}$), and that 0.5 $\color{ForestGreen}{currency}$ produced by that in-progress $\color{Cerulean}{Gen 1}$.

$t$=2, we’re up to 2 $\color{Cerulean}{Gen 1}$s, one of which generates a whole $\color{ForestGreen}{currency}$ (the $\color{Cerulean}{Gen 1}$ created in $t$=1) and one generates a half $\color{ForestGreen}{currency}$. Add that to the previous half and we have two $\color{ForestGreen}{currency}$ at $t$=2.

Now let’s graph it!

That $\color{ForestGreen}{currency}$ graph looks suspiciously like a parabola, no? It is in fact $y = \frac{x^2}{2}$. For those of you who remember your integrals, that equation will look familiar as the integral of $y = x$ (which is the equation that produces the blue angled line up there). Without going too much further down a calculus lesson, here’s the summary.

A derivative is a rate of change. In this growth model, each generator represents the rate of change of the next-tier-down generator, and thus can be considered a derivative. Because these are in sequence, we can effectively keep taking integrals from a starting point to see what growth becomes as you get higher tiers of generators. The series of integrals looks like this:

So if we had 4 tiers of generators, starting with a single $Gen4$, the $\color{ForestGreen}{currency}$ would be growing at $\color{ForestGreen}\frac{x^4}{24}$, and at time $t$ the total number of all generators would be $1$ + $\color{Maroon}{t}$ + $\color{BurntOrange}{\frac{t^2}{2}}$ + $\color{Cerulean}{\frac{t^3}{6}}$.

And, just to complete our circle, we’ll take a very quick look at an example from upper-level calculus. A certain type of infinitely summed series is called a Taylor Series, and there is a specific case that’s super relevant.

In other words, as we get more and more tiers of generators (as n goes up), we approach $e^x$, which is...exponential growth!

Okay, so that was a lot of theoretical math -- where did that actually get us? We’ve learned that setting up a chain of generators starts to approach exponential growth, which means it will have a lot of the properties that we had used in our exponential games. Plus, since you're not going to have infinite generators, you'll still always eventually lag behind actual exponential growth, so costs (at exponential levels) will still outpace production (with derivative-based growth) as we want. I also find that it just "feels" good - as you gain more tiers you get to see the lower tiers get truly huge - it's like having multiple AdVenture Capitalist games all working together!

There are a few games that already do this, perhaps most clearly is the aptly named Derivative Clicker by gzgreg (forked from icehawk78), seen in the animated .gif below. Note that the single Graduate Student ($\color{Maroon}{Gen 3}$) is producing one Undergrad ($\color{BurntOrange}{Gen 2}$) per tick, while the High Schoolers ($\color{Cerulean}{Gen 1}$, which produce dollars) being generated go up quickly -- 10, then 11, then 12, etc. as the Undergrads increase. Exactly as we set up above.

We can check out Derivative Clicker code to learn a little more, and indeed the costs are calculated using a basic exponential function as expected. The cost of High Schoolers for example is $5 \times 1.1^n$. So still exponential costs, and growth is happening sub-exponentially, which is perfect!

Cirrial’s Shark Game (a fantastic idle game if you haven’t tried it) also makes use of generators producing other generators; for example, the Nurse Sharks create Sharks that harvest fish.

One of the major balance issues to solve is how to keep purchasing of lower-level tiers relevant. As you can see in the gif above, I’m gaining lots of high schoolers every second, for free. Why would I ever buy more? The answer could be that you wouldn’t and you can design your game that way, but if you want to keep them relevant, well, gzgreg’s solution is an elegant one.

Notice that each generator up there has two numbers: a total owned, and then one in parentheses, which is the number actually purchased. The cost of a generator is calculated based on the purchased number, not the owned number. But more importantly, he has created tier boosts. For example, every purchased tier 1 building (like the High Schooler) boosts the production of all tier 1 buildings by 0.05%. This means that even when I have billions of High Schoolers, there’s still value in me being able to buy more manually, which creates a great sense of having lots of possible and influential ways to spend your resources.

One last point on the topic. What I laid out above is the simplest version of a derivative-based system, but as a game designer you have a lot more flexibility than that, and you should be open to exploring that space. For example, here’s the general cost and production chart for Derivative Clicker. Notice that it has two currencies and generators have dependency on the production of one another, which makes for some excellent interplay during the game.

So I would encourage you to explore different types of progression within your game. The standard all-generators-contribute-to-a-primary-currency progression is great and powerful, but it can also be combined with things like this derivative-based generator concept.

Make generators. Draw lines between them. See what happens! Maybe one generator can produce multiple currencies. Or multiple generators. Or maybe even more idle games. The world’s your oyster, have fun with it. :)

If you have questions, find a mistake, or have an awesome new idle game you want to share, please feel free to reach out and email me at anthony@kongregate.com. I also want to give credit to the tools used in this post: MathJax did the awesome live-rendering of LaTeX, Draw.io is a quick and free flowchart web app, and Desmos is a slick in-browser graphing calculator with some great educational functionality.

More articles you might like:

Hello, my name is David Finseth and I am a Technical Artist at Synapse Games. I work across multiple games to create visuals that require some technical and artistic components. A big part of my job is working on particle effects for our mobile games. I am very passionate about this work and wanted to share my process and some tips for creating these effects with you. Particle effects are a unique tool that can add interactivity and responsiveness to your games. They excel at creating a lot of movement and impact. Particle effects can be used to create magical fireballs, swirling dimensional portals, or for directing the player's attention to a glowing treasure chest. First, I am going to break down the process that I go through when I make particle effects in Unity. Later I will go over some technical tips and tricks. Most of these examples are from work that I did on the games Spellstone and Animation Throwdown. The Process Breaking down the requirements: The first thing I do when I start to make a particle

pictured: Thumper Dark Souls is more likely associated with anguish than euphoria as a series, but it -- and other notoriously difficult games -- are where we can find some of gaming’s most pleasurable moments. If you work through your urges to throw your controller at a wall, you might be lucky enough to experience the joy that keeps us all coming back for more “YOU DIED” screens. We’re going to delve into what leads to these experiences, why they feel so good, and how they can be designed. That feeling? It’s called “flow.” Named by Mihály Csíkszentmihályi in the 1970s in response to interviewees describing the feeling as being carried along by water, flow is a deep, pleasurable immersion in the activity you are engaged in. Most commonly used in reference to creative pursuits like painting or performing music, this experience is absolutely found in games as well. To find yourself in a state of flow, first there are some parameters: You know your goal You know how to accomplish your goal You are receiving feedback

KONG: Hyper Hippo is a Canadian-based independent game developer best known for the hit idle game AdVenture Capitalist. How did you all meet and start making games together? CODY: Hyper Hippo sprang out of the imagination of Lance Priebe, the creator of Club Penguin. He assembled what he felt was a "dream team" for game development, then opened the floodgates and said, "GO!" TRISTAN: We all met while working on the virtual world "Disney’s Club Penguin." We wanted to try our hand at some new game experiments, create new IPs (Mech Mice, AdVenture Capitalist, etc.), develop for leading platforms (mobile, PS4, Xbox), and move away from the processes and politics of larger companies. KONG: For those of us not familiar, what type of game dev culture does Canada have? What sets Canada apart from other development hubs? CODY: Canada is similar to a lot of other "game" or tech hubs, but maybe just more apologetic? We’ve got our big guys like EA, BioWare and WB Montreal. But there’s also