Game Design, Programming and running a one-man games business…

Designing a system of orders for units in a war game

So… I am sort of working on a game as a hobby. It may never be released. But anyway, lets pretend its a Napoleonic war game.(its not). That allows me to at least talk in non vague terms. I am stuck slightly in the way I am designing a core part of the game.

Imagine a game where you have to place down a large number of units, on a map, and give them orders. The game then plays out the resulting battle against a pre-placed AI enemy. These days the kids call that an autobattler, but AFAIK I made the very first one (Gratuitous Space Battles), so I didn’t have a name of it back then. Anyway…

The goals in the design for such a game are actually quite complex. The system needs to be intuitive, so it can be played easily by a fairly casual gamer, but also provide depth where possible, must ensure that the way things play out goes as expected by the player (they feel like they had real control over events), and must result in a visual outcome that looks appropriately cinematic, and not just like a bunch of idiots in a bar room brawl. (This is my #1 critique of all the total war games, that seem to descend into this). These goals are actually quite complex and conflicting, and I have spent a lot of time and code trying to reconcile them.

Formations

One of the clearest places where stuff falls apart is when it comes to formations. If you have a long line of units, and declare them to be a formation, then you are expecting them all to operate as one. My solution for this was to make all the units but one the ‘dumb followers’ of this one independent formation ‘leader’, which would be free to care about other orders. If the leader moves forward, everyone in the line also moves forward. Sounds simple enough to design & code right?

Nope.

Firstly, the leader may die. In that case we need a new leader, so the system has to hold an ‘election’ to pick the most appropriate replacement. Initially I chose the largest unit at the time of election, but you then encounter issues where the lead ‘unit’ may weaken down to 1% health, but is still the leader. Ideally there are periodic elections to ensure ‘leadership’ is tied to current strength, but this needs to take into account units healing and not result in leadership ping-ponging etc. Also in my game the ‘strongest’ unit does not necessarily visually make sense for deciding who leads and who follows. Just picking a leader is complicated as it is.

Its amazing what good condition the grass is in after a thousand soldiers have cartwheeled around on it to form patterns.

Secondly, how is the formation maintained? A line of units that represents a column in the Y axis looks good at the start of battle, but is the formational-consistency based on the initial x/y offset or does the line ‘wheel’ around the leader? If the leader turns to the left are we now doing a wheel adjustment? and if so, shouldn’t the leader be the unit in the middle, not the strongest?

Thirdly how do we handle gaps? If half the formation is destroyed, does our line now close ranks to form a thinner line? a shorter line? or do we just ignore the holes and continue as a depleted sparse formation? What would the player expect, and what looks coolest?

Engagement Range

This is the one that has just stumped me and made me write this blog post. For example, lets presume that your unit is not in a formation, but it has an ideal range to engage the enemy, due to its weapons, of 800 meters. How do we take into account this engagement range (and maybe a minimum range of half this?) when deciding where on the battlefield we need to be. So for example, a unit of cannons is looking all over the battlefield, thinking ‘where is the place I should head to now?’. How does it decide where to go?

The first system I have coded looks ahead and slightly to each side, and evaluates every square it could move to and gives them a score. For each square, it looks at all the units, in all the nearby squares to this potential target site, and counts up the values of all the potential targets for each square. There is then some minor tweaking to penalize far-off squares, and a hellishly complicated system of ‘reserving’ and ‘occupying’ squares so that the units don’t all end up stacked on top of each other. All of this code is written, and to some extent it seems to all work but…

…you then get the Total War bar-room brawl situation because it turns out that with this algorithm the ideal place for every unit is to be slap bang in the middle of the battle where it can shoot at absolutely everyone. Hence the big furball of messy collision in the middle of the map.

My first thought is that this is just something needing a minor tweak. If units heavily prioritized locations where enemy units were within a certain percentage of the engagement range (in this case say between 600-800m) and actually penalized places where enemies were within that range (say under 600), then you would get the long range units more sensibly placing themselves at a nice aesthetically pleasing distance where they could shoot at each other in a classic war movie style.

I can throw a banana further than this. WTF is their engagement range set to?

The Bigger Question

However, I am starting to wonder if that is all a load of bollocks.

There are three different scenarios under discussion here. The military reality of what makes sense in a real war to win a battle. The movie version, where the goal is to look cool, and the game version where the goal is to be fun, and intuitive and satisfying to tinker with as well as watch. I have definitely been starting from a real military position, which is at the total other end of the spectrum in terms of where I need to be (a fun game!).

One of the primary drivers of the code I have written so far is that it is supposed to seem like it makes sense for military units to do this. But as a game, I kind of don’t really care. Games are not vaguely concerned with the inconvenient truth of military history. We want things to feel fun, even if that means the choices make little sense. It might be TRUE that a line of 10 gatling guns on a hill could obliterate an entire roman legion, but after seeing it once, is it still fun? Not really. What wargames like this focus on is a sort of block-puzzle game, where carefully mixing and matching and positioning units ‘unlocks’ a solution, which is a complex feat of ‘combined arms’ resulting in a close victory.

One of the great things about modern gaming is we can make some really cool special effects, and use massively powerful video cards to draw amazing spectacles. That takes a bit of the pressure off of designing a game that is so intricate in the abstract. I used to play a tabletop war game called Starfleet Battles. Its LUDICROUSLY complicated, and a single turn can take an hour with a group of players. The ‘fun’ comes from the complex interactions of highly detailed systems. It has to, because the actual experience is just hours staring at pieces of cardboard on a map, hoping nobody sneezes.

I was ludicrously obsessed with these games back when I was young and before electricity was invented.

Simplification

I’m not exactly known for simple games. But there are certainly companies that outdo me. The Hearts Of Iron games are just way beyond me, in terms of the amount of stuff to keep track of, and Eve-Online has become a game seemingly more involved than life itself. These games also have 100+ developers working full time, and this game is a hobby project I am spending an hour or so a day on, so its not going to go in that direction…

…and genuinely I am starting to consider the idea that my game should more resemble a simple puzzle game more than a complex uber war simulator. The amount of variables will still be high, and the outcome very pleasing. I think the cool ‘fun’ element of games like this is ‘I tried this… it failed, but was an awesome battle. I’ll try again’. It shouldn’t involve multiple hours of tweaking individual units decimal points in the AI decision making. Maybe the whole army is always just ONE formation, and it just moves right at the enemy as a single cohesive pattern? Maybe all the complex route-planning AI is utter bollocks? There are definitely a ton of much simpler games out there that seem to do this. I wonder if thats what a ‘roguelike deckbuilder’ game is? (I am sick of the term, but still don’t really understand what it means tbh).

Anyway, it might all be academic, as I might get bored and make something else. But I might not :D.


7 thoughts on Designing a system of orders for units in a war game

  1. Thoughts upon reading this:
    – Does a formation need a leader? Could you just treat the whole thing as a kind of meta-unit instead?
    – Would real battles not devolve into those bar room brawls? If not, why not?
    – If you’re going to lean into the puzzle direction, check out Into The Breach if you don’t know it already. It’s one of a kind.

  2. I think that if you want to have fun with formations, you can make designated leader units that control the formation, and if killed will cause the formation to descend into bar-room brawl mode. Games like Total War don’t use this system because it’s obviously annoying to lose control of half your army, but with an auto-battler you’re already giving control away so it’s no big deal, and can be a fun and flashy way to have units fall apart.

    1. Thats actually quite similar to the redesign I attempted today, although the leader unit is passed down a hierarchy. It would be fun to have the player define the priority list of formation leaders maybe :D

  3. Depending on the level of input you allow after the battle has started there’s a lot you can do with “commanders’ intent”. At the minimum there’s the usual ‘hold this area’ and ‘attack forward’ or ‘charge’ and if you allow input after the battle has begun then ‘rally on position’ or ‘dig in here’. You could add in conditionals like ‘do not engage until unit strength of a supported unit falls below a threshold then add to that unit’, basically creating reserves. Are you having terrain obstacles and fog of war? If so place cannon or mortars in protected areas and set ambushes again with real time orders or conditionals of enemy range, ‘don’t fire ’til you see the whites of their eyes’.

    Also do you handle retreat as a tactic and/or units being routed? In those cases maybe combine under-strength units to be commanded by the strongest leader among them them rejoin the fight? That might help with your formation issue.

    Maybe you could do building a ‘battle ai’ like those visual coding/game languages (like Apache NiFi). Drag and drop orders and conditionals with parameters into a tree of options that runs on top of a state machine and let it make the real time decisions after the battle starts?

  4. For the kind of game you outlined I suspect complexity may work against it being fun.

    To be able to make strategies against the computer I really think you need the ‘AI’ (whether friendly or enemy) to behave according to simple and obvious rules, so the player can learn them and shape a deployment strategy to exploit them. Complexity comes from the interaction.

    It’s great if your plan all falls apart because of something you didn’t correctly predict, but is a logical consequence of all these simple rules interacting. It’s terrible if your plan fails because your own fighting AI goes off and does something utterly baffling with it that makes no sense to the player.

    Thinking of examples, games like Bridge Builder, Kerbal Space Program or Tears of the Kingdom let you come up with plans that can utterly fail (or miraculously succeed) in hilarious but always understandable ways, because everyone has an intuitive understanding of the basic physics. Simultaneous order games like Colt Express or Laser Squad Nemesis also let you see how your carefully thought out and logically executing steps can rapidly degenerate into a totally chaotic mess on contact with an opponent, but they always make sense.

    Adding a lot of randomness or too clever AI to the mix (essentially the same thing – if you don’t understand what it’s doing it’ll seem random anyway) ruins the connection between plan and action. Fighting goblinoid armies in Warhammer: Shadow of the Horned Rat comes to mind, because the WFB rout rules are so random but punishing that the exact same strategy can have wildly different outcomes based on some invisible dice rolls.

    1. Yes agreed, I think the simpler the better. The complexity will come from options and their combinations rather than clever-ass AI :D.

  5. Wow. Starfleet Battles. That brings back memories. Loved that game.
    Good luck with this. Hope to see it.

Comments are currently closed.