Cold Takes/5 - Making Metal

From Zero-K
Jump to navigation Jump to search

Cold Take #5 - Making Metal

Posted 27 January 2024


Games in the Total Annihilation lineage almost always have the same two resources, metal and energy. Metal is produced by building Metal Extractors on deposits scattered around the map, while energy comes from power generators that can be built, by and large, anywhere. The more important resource is metal, simply because metal deposits, or "spots", are rarer than free space to produce energy. Metal is the limiting factor, which causes players to expand out onto the map, capture territory, and interact with the enemy. A game without metal would mostly consist of players sitting in their base, building energy.

Many TA style games also have Metal Makers, economic structures that drain large amounts of energy to produce a bit of metal. Supreme Commander calls these Mass Fabricators, but mass and metal are just two names for the same thing. These structures are less efficient than metal extractors, otherwise players would have no reason to leave their base, but they allow players to scale up their economy without capturing more metal spots. The only requirement is space and resources, which makes them useful later in the game when all the metal spots are taken and defended. The early developers of Zero-K liked the idea of a growing economy, but not how it was implemented with metal makers.

Metal makers.

Metal makers were removed from Complete Annihilation, the precursor to Zero-K, just about as soon as it forked from Balanced Annihilation. For context, the average 8v8 BA team game had a few players on each team fighting over unclaimed territory, while the rest of the team sat in the back and mostly built metal makers. The back players players were not slacking, they were necessary, because games were rarely won before metal makers became a deciding factor. Any team that ignored metal makers risked being overwhelmed by the compounding income they would eventually provide. Eventually, once a team had enough metal makers, territory no longer mattered. This did not sit well with the CA developers, as they preferred fighting and expanding to sitting in the back.

Metal makers are fundamentally a way to spend resources now to be more powerful in the future. Every RTS needs something like this, some way to invest in the future. Investment can take many forms, from simply increasing income, to upgrades that increase how much power you can squeeze out of your existing income. Investment is vital because it is a dimension of the strategic triangle, with the other two dimensions being aggression and defense. Without investment, there would be no way to outproduce and overwhelm an overly defensive opponent, and there would be nothing for aggressive play to punish. So we knew that CA needed some form of investment. We tried subsisting on advanced metal extractors, another feature of the TA lineage, which are expensive income upgrades for basic metal extractors. These were a bit finicky though, and the ability to invest hits a wall when there is nothing left to upgrade, so we came up with overdrive.

Do we want metal makers?

Just as an aside, I recall discussion on the Planetary Annihilation forum about whether it should have metal makers. It ended up without them, and without a replacement, which might be fine, although I lost track of PA so cannot say for sure. I suspect relying on advanced metal extractors works because there is a lot more frontier to defend when playing on a planet, and PA was fairly spammy with its metal spots. So upgrades can carry the investment game, just in CA's case the maps tended to not have a ludicrous number of metal spots.

Anyway, CA went with overdrive, which may have been invented by Licho. I know he at least wrote the first version of the code. The basic idea is that every metal extractor (mex for short) should also be a metal maker, because that links metal makers to territory. A complete system can then be derived by noticing and fixing a few immediate issues.

  • Metal spots can be high or low yield. It would be weird for a map of low yield metal spots to allow more metal maker income than a map with fewer spots and the same total income. So the "metal maker" income of a mex is a multiple of its spot yield, rather than a fixed amount.
  • The standard "drain 70 energy for +1 metal" style metal maker has the same issues as advanced mexes. In particular, economic investment hits a sudden limit when enough energy is being produced to run all your mex-metal makers. So we made mexes able to turn a variable amount of energy into metal.
  • A variable input metal maker cannot have a fixed conversion ration, otherwise players would only ever need one. This would defeat the whole purpose, so we made a mex's energy to metal conversion efficiency worsen at higher rates of energy use.

The result was mexes that can drain X energy to multiply their income by 1 + √(X/16). We call the extra income overdrive income, so for example, a mex with +2 base income doubles its income by draining 16 energy per second, and would need to drain 64 energy to triple it. Actually, the original equation was (1 + X/4) − 1, but near the end of 2014 we discovered that it had not been solved correctly, and that the correct solution required the concept of "underdrive". So we switch to the simpler 1 + √(X/16).

The diminishing returns of overdrive keep territory relevant throughout the entire game. Say there are two teams, one with 10 mexes and the other with 8, which each have 40 energy to spend on overdrive. The energy is automatically split between the mexes, as this yields the greatest return, so the teams spend 4 and 5 energy per mex respectively. Spending 4 energy on a mex increases its income by 50%, while spending 5 energy increases its income by 56%. Assuming +2 base income mexes, the team with more mexes produces 10 overdrive metal while the other team only produces 8.9. So territory is important because it lets the team with more mexes convert the same amount of energy into more metal.

Metal maker vs Overdrive.

Overdrive was also a break from the exponentially increasing income characteristic of standard metal maker economies. With metal makers, you can always spend a fixed amount of metal for the same increase in income, and this income can be reinvested in increasing your income, yielding exponential returns. With overdrive your income can still grow, but further growth becomes increasingly expensive. These two factors cancel out, leading to high initial returns followed by approximately linear growth, since spending twice as much energy on overdrive only increases your income by 41% (√(2)). The graph above demonstrates the difference, with overdrive via Singularity Reactor pitted against a modded metal maker. The metal maker does not drain energy, rather, it represents an energy-neutral combination of metal makers and power generators.

Removing metal makers was also great on the fighting the UI front. It takes skill and attention to scale up a metal maker economy since energy production needs to be balanced against expenditure. Overbuilding power generation is wasteful because the excess energy is lost, while overbuilding metal makers leads to a deficit. Metal makers can be turned off to avoid stalling, but idle metal makers represent wasted resources that could have been used to generate more energy. Truly optimising your income is hard. Overdrive does away with this. If you want to increase your income without more metal spots, just make energy and let your mexes automatically drain the excess. The underlying decision, to invest, is the same across games, but getting the most bang for your buck is tricky with metal makers. Players using either system still have to balance exploiting their existing territory against expanding into new territory, but that is an important strategic decision that involves the enemy, so Zero-K retains it.

Overdrive also led to some interesting map design around high yield metal spots. Mexes drain energy to multiply their income, so better mexes are more efficient and should use a larger fraction of the available energy. The overdrive system figures this out automatically, with the optimum split being to weight each mex by the square of its income. So a +4 mex should receive 4× the energy of a +2 mex. Map makers take advantage of this system by putting high yield metal spots near the centre of the map, for "king of the hill" style objectives that become increasingly important as the game progresses. The high yield mexes are valuable early, but not unduly so, because excess energy is scarce. It is only later in the game, once people have built up their energy, that holding high yield mexes confers a significant economic advantage.

Connected grid.

The initial implementation of overdrive had a few problems. The very first version presented players with a graph and a slider bar to control how much energy they sent to overdrive. That was quickly replaced with an innate system that spends a proportion of your net income that depends on how much energy you have stored. The first version might have also been per-player, rather than pooling team mexes and energy for improved efficiency, but if so, it was revised quickly. In any case, there were other reasons to have shared mex income. Overdrive had one tricky, nuanced, problem, which we solved by adding an energy grid. These days overdrive is synonymous with the energy grid, but the entire rest of the system was designed without it.

Grid-less overdrive was a bit prone to snowballing. A small difference in the number of mexes controlled by each team results in a persistent income advantage. More precisely, the energy to metal conversion ratio is (X/Y) times better for a team with X mexes compared to a team with Y mexes, for the same input energy, assuming uniform mex incomes. This would compound into victory for the side with a slight advantage, before it "was time" for the game to come to a conclusion. The solution was an energy grid, so that overdriving a marginal mex required a bit more effort than just building the mex. Then a team with a slight advantage has to hold onto their mexes, and to build some vulnerable infrastructure, if they want to compound their improved overdrive efficiency into victory.

The energy grid works by setting a simple constraint: the total energy used by mexes in a grid cannot exceed the energy produced by structures within the grid. This makes overdrive usage mirror the roll-out of advance mex upgrades in other games. Players start by upgrading their main base, and then expand to increasingly dangerous territory. It creates a satisfying wave of "double expansion", where you have secured territory well enough to fully exploit it for resources, and the extra infrastructure is also extra raid-able.

Pylon grid.

The first grid was designed around dedicated pylons. These pylons gathered energy within their radius, and were the only structure that could link to mexes and to other pylons. As well as being too complicated, the system suffered from the distance threshold problem. In short, previously irrelevant minor variations in map symmetry were now extremely important. A pylon might cover four mexes on one side of the map, but only three on the other, conveying a noticeable economic advantage. We tried imposing a hard connection limit of three, and tweaking pylon radius, but maps were too variable to cover everything, and our attempts were making pylon placement increasingly fiddly. So we let everything link to everything, letting pylons fade into the background. This all happened rather quickly, the grid as it exists in Zero-K today may have been complete as early as 2008.

Letting everything link to everything turned out really well. Many RTS games have at least one spammy economic structure, most commonly houses or power plants, that can be built anywhere. Players will just pack these structure into the back of their base unless the game gives them a reason not to. Most games of the TA lineage let this happen to their power generators. Supreme Commander had a go at solving this with its adjacency bonuses, but personally I feel like they make base building a bit too prescribed, and packing a checkerboard of power generators and metal makers into the back of your base does not seem like much of an improvement. The way players make energy in Zero-K is so interesting, so flexible and alive, by comparison.

Flexible grid.

Players tend to start on their grid from the start of the game. They drag lines of wind generators between metal extractors, but these lines are perfect cover for enemy raiders. Expanding constructors might also build the occasional solar collector, which spices up expansion patterns and creates more targets for raiders. Two solar collectors are enough for a 50% increase income boost, so people often roll them out as cheap form of secondary expansion before fully gridding everything later. Placing energy in interesting ways becomes automatic, you can sometimes spot Zero-K players in other games this way. Giving players a reason to care where their energy is built creates so much nuance and variation in expansion and base layout.

Overdrive has a big drawback in that it can be harder to explain than metal makers. Telling someone about a structure that turns a fixed amount of energy into metal feels like a complete explanation, even though it leaves out all the detail of when you might want to use this structure, and how to manage an economy around it. The basics of overdrive can be explained with rules of thumb such as "build more energy than your metal income" and "link energy to mexes', but these are a bit too vague. Some players want solid numbers, even before they have the context for them. All we can give them is the energy conversion equation, and the way grids limit energy expenditure.

The trickier explanation of overdrive goes hand-in-hand with its role in Zero-K. For all its apparent complexity, I contend that mastering overdrive is easier than mastering metal makers. In general, systems made of simple discrete parts, such as metal makers, tend to be more complex than systems of smooth equations. Zero-K exploits the emergent complexity of simple elements in much of the rest of its design, but not at the core of the economy. This is simply because Zero-K is not a game about micromanaging your economy to eke out an optimal growth curve. Such a curve can be solved, and the solution has nothing to do with fighting the enemy, so we consider it to be fighting the UI. Rather than metal makers we have overdrive, which solves itself, but which has enough going on around it to remain interesting after it is solved. The different energy structures, with their different incomes, costs and vulnerabilities, act as our simple elements with emergent complexity.

Grids with different efficiency.

We try to ameliorate the complexity of overdrive with mechanics that help players play it by ear. Grids change colour based on how efficient they are, and energy structures show an estimate of their payback time as they are being placed. This seems to work for the majority of players, and the system is very forgiving, because overdrive cannot cause an energy stall. Hopefully we do enough to get new players over the hurdle of using something so different, until they realise how smooth it is and how many problems it solves.