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.