Kittens Game is a clicker game that you can play in your browser. It makes a strong first impression, as it tempts you into choices that will kill off your kittens within twelve minutes. But I’m not here to review the game, I’m here to talk about spreadsheets!
Clicker games often support passive gameplay (e.g. leave it running overnight), active gameplay, or any combination of the above. On the very active end, you could try to optimize it, setting up spreadsheets to run calculations. So, I spent a thousand years tinkering with spreadsheets, and I liked it. There’s a story there, a mathematical story.
Basic concepts
The main question that my spreadsheets try to answer is: which of the dozens of buildings do I choose to build at any given moment? I can build multiple copies of each building, but they get exponentially more expensive the more you have. Therefore, the optimal strategy is to spread out into every kind of building, in proportions determined by their cost and benefit.
But the costs and benefits are difficult to measure, as there are multiple incommensurate resources. How many minerals are equivalent to one wood? How many iron are equivalent to one mineral? And so on.
The easiest calculation to make, is the conversion between minerals and wood. You have a settlement with a certain number of kittens, and kittens may be freely assigned between various jobs. A woodcutter produces 0.09 wood per second, and a miner produces 0.25 minerals per second. So a mineral is worth 4 kitten-seconds (think of them as man-hours), and a wood is about 11 kitten-seconds. Easy.
A more difficult question, is the value of iron. Iron can’t be produced by kittens, and is only produced by a building—the smelter. The smelter consumes resources over time, and initially I tried calculating the cost of iron based on the resources consumed. But this leaves out the cost of building the smelter in the first place. And the cost of a smelter grows exponentially with the number of smelters.
In the end, I just manually adjusted the price of iron. If I have too much iron, I adjust the price downwards; if I have not enough, I adjust it upwards. Price adjustments nudge the simulation either towards building more things that produce iron, or building more things that cost iron. Price-setting is the best approach to many resources. It’s very flexible and allows space for intuition and guessing in case of limited information.
On the other hand, once I’m looking at a dozen different resources, it’s too much work to perpetually be adjusting all of the prices. So I set iron prices to be inversely proportional to gross iron production. That seemed to reduce how often I needed to manually adjust the price.
There are, of course, many more complexities, but I’m just going to discuss a couple particularly interesting wrinkles.
Resource caps
One of the most challenging things to evaluate is the value of higher resource caps. For example, I might start with a resource cap of 100 minerals; any minerals gained above 100 are wasted. Increasing the minerals cap gives me more room to operate without wasting resources. Also, if there’s a building that costs 150 minerals, then I can’t build that until I increase the resource cap to at least 150.
I spent a lot of effort trying to quantify the latter effect. If a higher minerals resource cap allows me to build more smelters, then how do I calculate the value of increasing the minerals cap?
My first approach was similar to my approach for iron: I just manually set the price. When I build a warehouse, that increases the minerals cap by a bit, and according to my prices that’s worth a certain number of kitten hours. If the simulation wants me to build more smelters, but the minerals cap isn’t high enough, then I adjust the prices until the simulation demands more warehouses and/or fewer smelters.
The problem is that this requires adjusting prices on a very frequent basis.
There’s a second problem which is more subtle. Suppose there are two buildings limited by the minerals resource cap: workshops and smelters. The value of increasing the minerals cap should be the “sum” of the two types of buildings, but my price-setting method only depended the “max” of the two buildings. Therefore, it systematically underestimated the value of resource caps.
So I eventually completely revamped the calculation. First, the spreadsheet calculates the net value of each building while ignoring resource caps. This net value is divided by the requisite resource cap increases, and it’s summed up over all buildings. The calculation isn’t perfect, but it completely eliminated the need to manually adjust the price of resource caps.
Unicorns
Let’s think about units. Generally, a building costs a certain number of resources, and these resources can be priced in kitten-seconds. The benefit of a building is usually a boost to economic production, i.e. some number of kitten-seconds per second, or simply kittens. The benefit:cost ratio of a building is kittens per kitten-second, or simply inverse seconds. One way to think of it, is that the benefit:cost ratio is one divided by the amount of time it takes for a building to pay for itself.
I generally built the buildings with the highest benefit:cost ratio. However, this doesn’t account for the time required to save up resources to build in the first place. If a building takes an hour to pay for itself, but two hours to gather the resources to build it in the first place, how valuable is it?
For the most part, my calculations ignore this factor. Too much work to make it more accurate! But I decided not to ignore it when it came to unicorns. Unicorns are a resource that take a particularly long time to gather. They’re also mostly separate from other resources, allowing me to treat them as a self-contained system with relatively few complicating factors.
So rather than calculating a benefit:cost ratio, I instead modeled unicorns as exponential growth. Let’s say that I double the rate of unicorn production every N seconds. What is the implied value of N for each building? I’m not going to go through the mathematical equation, but it involves logarithms. It was satisfying to set up and see how it impacted the unicorn-related choices.
TL;DR
Yeah, you can treat clicker games as mindless time-wasters, and there’s nothing wrong with that. But if you’re interested in optimizing, they present a lot of complicated problems, with multiple approximate solutions. A central challenge is comparing the value of different resources that can’t be directly exchanged for one another. Another challenge is reducing the amount of manual attention required to maintain the economy. If you like playing with spreadsheets, clickers can be a fun activity.
JM says
These clicker and idle games are like the easier platform games. If you plug away at them you will eventually win. Trying to get every achievement or speed running the game can still be very complex and require increasing amounts of analysis. I don’t think this is any intentional planning it’s just a natural consequence of easy games.
There is also an element of any game with an economic system tending to explode in complexity. Every purchase you made is other purchases you didn’t, so every element interacts with every other element. As soon as your trying to be efficient the complexity of the economic system increases geometrically. You see the same thing in RPG games. When just playing casually it’s just a matter of how much time you want to grind gathering money. When your trying to speed run the game buying the right items in the right order to maximize money and power becomes important.
Perfect Number says
Oh wow, this game is fascinating. It is crying out to me to make a spreadsheet to figure out how to optimize it.
(Also the first time I tried it just now, my kittens all died within minutes because I didn’t know they needed to consume resources.)
Siggy says
@Perfect Number,
To a prospective player of Kittens Game, I would say that for a clicker game, it’s particularly long and slow. That’s what makes it amenable to spreadsheeting, but it’s also a big time sink.
Perfect Number says
How long does this game go? Mine has been running “17 years” and I get the feeling it can run way longer than that.
Siggy says
@Perfect Number
I have ~2 millennia. Each year is 800 seconds. So that’s about 450 hours. Although, there’s also a time acceleration mechanic, and you don’t necessarily need to pay attention to it the whole time. It rivals the play time for my most played games on Steam (Prismata, Slay the Spire, Factorio).
jenorafeuer says
Hunh. Clicker games as examples for teaching the principles behind Linear Programming. I bet some University level algebra professor could actually make that work, and it might work better for some people than the traditional logistics examples.
Perfect Number says
Okay a few more things
– What if I leave it running overnight and all my kittens starve to death when I’m not paying attention?
– Did you play the whole thing first, to understand all the possible upgrades, and then try to optimize it?
– For “optimizing” it, it depends what the goal is- seems like there are different possible directions you could take this kitten society, right?
Siggy says
@Perfect Number
– I think kittens will continue to move in to your village, although they won’t be assigned jobs.
– I tried a few times without spreadsheets, before restarting with one. I don’t think you really need to know upgrades in advanced, although I look up some questions.
– Maybe? If the goal is number-go-up, I think there’s a single dominant strategy. But the strategy may depend on how much you prefer to leave it on overnight vs actively maintaining it.
– Also, something that isn’t obvious, is that to advance, you’re supposed to occasionally use the time tab to reset.