Cold Takes/8 - Smoothly Flowing Economy

From Zero-K
Jump to navigation Jump to search

Cold Take #8 - Smoothly Flowing Economy

Posted March 9, 2024


Zero-K uses a flow expenditure system, which is the system of choice for games of the Total Annihilation and Command and Conquer lineages. However, we break from the rest of the TA-like games by paying particular attention to making the economy flow smoothly, in stark contrast to the unforgiving economies that tend to define the subgenre. This is because Zero-K is about fighting the enemy, not about micromanaging your base, and it also demonstrates how flow economies are not necessarily daunting.

Smooth production.gif

A flow expenditure system works as follows:

  • The player issues a construction order, and the construction begins.
  • Resources are spent over the course of construction, such that a task which is XX% complete has consumed XX% of its cost.
  • If you run out of resources, then construction rates are reduced to balance your income with your expenditure.
  • When construction progress hits 100%, the construction is complete.

For example, if you produce 16 metal/s (metal per second) but your total demand is 20 metal/s, then the each of your constructions builds at 80% (16/20) its maximum rate. Think of it like pouring water into a bucket. When the bucket is full, the construction is complete.

Many games use an upfront payment system as it is the main alternative to flow expenditure. Examining it will reveal why Zero-K uses flow instead, so here is how upfront payment works:

  • The player issues a construction order.
  • The order is blocked if the player has insufficient resources to pay the full cost of the unit or building.
  • Otherwise, the cost is deducted from storage, and a timer starts.
  • When the timer finishes, the construction is complete.

Upfront payment is a very simple system, and there is strength in that, but using it well can be difficult and time consuming. As we saw in Making Metal, systems of simple discrete actions often end up being more complicated than systems that work more continuously.

Mastering an economy is fundamentally about reducing downtime as any time your factories are not running is wasted time. Upfront payment gives players very few tools to do this, which leads to fights with the UI, and these fights can take over entire games. More specifically, to master an economy you want to keep your money low, and to do that without breaking your keyboard, you probably need command queues.

Knights vs storage.png

The saying "keep your money low" is good general RTS advice. The return on investment is so high in RTS, relative to the utility of waiting for more information, that stockpiling is rarely worthwhile. Investment could take the form of expanding your economy, defending it from attack, or attacking the enemy economy, it all helps. Sometimes stockpiling 100 metal to boost out a turret is warranted, but generally, to not spend resources is to fall behind. So how do the two expenditure systems compare? Well, flow expenditure makes having zero money easy, just make sure your demand exceeds your income. Upfront payment makes keeping your money low much more difficult. Approaching the ideal with upfront payment means watching your resources like a hawk, ready to pounce as soon as they hit the threshold required to buy something. This eats up a lot of attention and can even require training to truly master.

Many games have production queues that let players queue up a list of things to be built, regardless of the spending system. Unfortunately, upfront payment queues leave a lot to be desired, as the standard implementation has you pay the full price just to queue a unit. A queued unit is making no progress towards being built, so this is just as bad as having the resources sit idle in storage. These queues are useful for freeing up attention, but they always come at the cost of efficiency, and long queues are terrible. Other upfront payment queues only spend the resources when the task hits the head of the queue, delaying it if there are insufficient resources. This is much more like a UI feature than an Ability, in the language of UI vs. Game World, since it simulates the player clicking the buy button when the threshold is reached. It also allows for infinitely looping queues, which removes a lot of busy work, but has some pretty dire side effects.

Plate with Knights.png

The issue with paying when a task hits the front of the queue is with low-money situations. Suppose you want to make an army of cheap infantry and expensive tanks. You queue a bunch of tanks and infantry, then go do something else, only to return to an army of only infantry. The tanks spent all their time blocked at the front of the queue, never reaching their cost threshold, since the cheap infantry would consume those resources first. Even worse, to build anything you now have to cancel all your queued infantry and let your resources stockpile. This is not entirely realistic though, since the only game I know of with this system Warlords Battlecry, and as a fantasy game it lacks tanks. Anyway, flow expenditure is great for queuing since construction rates fall uniformly in low-money situations, guaranteeing a mixed army of infantry and tanks. Flow also allows for infinitely looping queues, so your factories run themselves until you decide to change your army composition.

This all begs the question, if flow spending is so great, why do so many games use upfront payment? Here is what I think.

  • Flow is a bit more complicated than upfront payment, especially when it is not the expected default.
  • Flow has a reputation for being a lot more complicated than upfront payment.
  • Putting anything approaching optimality beyond the reach of most players is often the point.

Upfront payment is a quintessential "easy to learn, hard to master" system, since it makes you do everything manually. This is great for pro players pushing the limits of what is possible, and it also lets newer players slowly build their base without being overwhelmed. Contrast this to flow, which has momentum that keeps going when you stop clicking on it. Upfront payment is like stacking boxes, while flow is like driving a truck. The average player can get a lot more done with flow, but can end up in trouble if they push down too hard on the accelerator.

Moving storage.gif

To be fair, the reputation for complexity is more for the TA-style economies rather than Command and Conquer. C&C only has one money resource and its build rates are high. TA economies effectively have three resources that must be kept in balance. Two money resources; metal, energy, and a third, build power, which is the rate that a constructor or factory progresses production. Construction rates are limited by the most in-demand resource, so stalling (running out of) energy means stockpiling metal until the problem is resolved. However, using up the stored metal requires extra energy, which puts you in danger of wasting energy. Managing these fluctuations can take up a lot of attention, potentially even more than an upfront payment system (depending on the game), and feel quite unwieldy. However, unforgiving fluctuations can be dampened. They are a design decision, not inherent to flow, and one that Zero-K aims to avoid. For starters, overdrive makes it very hard to actually waste energy.

The most complicated part of many TA-like games is their love of seemingly arbitrary metal:​energy:time ratios. One unit might cost 109 metal, 911 energy and take 19.6 seconds to build, while another might cost 150 metal, 2100 energy, and take 34.2 second to build. The former drains 5.6 metal/s and 46.5 energy/s while under construction, while the latter drains 4.4 metal/s and 61.4 energy/s. Those are some weird numbers, but what do they mean? They mean you might be happily building the first unit, switch production to the second, then crash your economy right into an energy stall. In many games the stall could even completely disable your metal extractors, adding to the chaos.

Build race.png

Zero-K avoids these economy-crashing traps by setting all costs in a 1∶1∶1 ratio. A unit that costs 200 metal must also cost 200 energy and 200 work. Build power, which is a constructors' ability to progress construction, is set to nice friendly numbers, such as 5 or 10. Since costs are 1∶1∶1, a constructors' build power is also its demand for metal and energy. Factories have 10 build power, which means they drain 10 metal/s and energy/s regardless of what it builds, and so any factory would take 20 seconds to build a 200 cost unit. This was one of the very first changes made in Complete Annihilation, and costs were rounded at the same time as well, because balancing the cost of units down to three significant figures is folly.

Flow expenditure with 1∶1∶1 ratios gives us powerful queues and avoids unforgiving economic complexity, but this was all still a design trade-off. Variable cost ratios can be interesting since they feed back into which resources you focus on collecting. This creates strategic momentum and scouting opportunities, especially in games with extreme ratios such as Starcraft and Age of Empires. TA tends to use ratios for a few special cases in the economy, as well as for general thematic trends, such as hulking ships being metal-heavy, while lightweight aircraft cost mostly energy. I am not sure whether varying ratios and flow is a good combination though, since the complexity ramps up quickly. Also, varying ratios tend to need puzzling out, which leads to long inflexible openings (build orders), which is something else Zero-K tries to avoid.

Income-demand no prio.png

Parallel production poses a few problems for flow expenditure. Recall how production slows down when your demand exceeds your income. Well, if your demand far exceeds your income, then it can be hard to build anything new. This is like the Warlords Battlecry queue problem, but much more palatable since everything is still built, and it takes an extreme deficit to get into real trouble. There is a subtle issue underneath though, which is that incomplete construction ties up resources, so building many things slowly can be as bad as a leaving the resources unused in storage.

Zero-K, along with many other TA-style games, addresses the parallel production issue by emphasising assisting, which lets multiple constructors pool their build power on a shared task. They can even assist factories, saving you from having ten 90% complete tanks. The extreme deficit problem persists though, and in many games you have to go through your whole base shuffling around or pausing constructors to prioritise anything. This is a clear case of fighting the UI, so Zero-K has construction priorities, which were added all the way back in CA.

Construction priority is a state toggle that let you set what gets first dibs on resources. High priority constructions are satisfied first, so they only slow down if too much is set to high priority. There are three levels of priority, and they can be set on constructors to control how they spend resources, or on construction projects to control how resources are spent on them. Priorities can even be given default values, so you can make metal extractors always be built with high priority. Once we added priorities it only seemed natural to add a reserve system, which lets you set aside resources for high priority use. Just Alt+Click on the resource bar. This is how you might set aside 100 metal to boost out some turrets.

Income-demand prio.png

Flow has worked very well for Zero-K. It lets players use proper production queues, and much of its reputed complexity is a decision designers make, not a fundamental part of the idea. Most of the magic is in ​the 1∶1∶1 cost ratios, with not-insignificant contributions from round numbers and construction priorities. It is harder to destabilise your opponents' economy, but on the upside, learning how to make a stable economy is much easier. The upside is worth it in our view, because it lets players get on with playing the rest of the game, and very few real in-the-moment decisions (as opposed to preset build orders) about how to grow your economy were lost.