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.
Leave a Reply