Artificial Intelligence is fairly dismal in quite a few RTS games. Instead of trying to play as if it were a Human player, the AI uses “brute force” tactics – in other words, cheating. It gets boosts to productivity, to resources and in some cases even to the damage done and taken by its units!
It is helpful to the AI if units are more “generic”, if there’s lots of overlap, but that has obvious gameplay consequences. On the other hand, choosing the wrong units in R/P/S games, where you need “counters” for the enemy units quickly leads to defeat. This leads to another form of cheating – where the AI knows what you’ve built and works to counter it. This is often mis-sold as some form of “learning” in the game AI.
This sort of cheating comes across, especially when done in heavy handed ways, as very immersion breaking and frustrating. It can have a limited role when done in more subtle ways, unlike games where the AI is deterministic and always acts in the same way – that rapidly becomes boring, and is something to avoid. AI’s need randomness, or they can be outmanoeuvred by Humans relatively easily, even if the AI has a huge “brute force” advantage.
Total Annihilation (TA) has a number of third parties AI’s which actually manage to do quite well, with a very limited set of tools – in fact, choosing what to build in TA is based entirely on weighting, there’s a % chance that a factory will build any of the units assigned to it. While there are tricks like AI-only units, this remains a limited toolkit and much of the challenge comes because AI’s have been honed for literally years – the base AI is fairly poor! In addition, in many cases the AI’s are good because they’re both honed for specific maps and they ignore large numbers of units. Still, the base concept works better than more complex base mechanisms in some other RTS games.
Still, for a good RTS AI, we need more tools to adjust what the AI can do. Let’s assume that there’s a more limited unit selection than TA, and that units have defined roles, aimed not at RPS but at combined arms. We need to clue the AI into how units work, and we can borrow from an internet concept to do so – metadata. We can tag units such that the AI knows their role and which types of unit work well together. It’s not about giving the AI absolutes, it’s about letting it adjust the chances of building certain types of unit.
Let’s take an example of that. Early in the game, the AI “knows” it needs to explore. So, it can build units tagged “Scout”. I mention this for a reason – the AI should make sure that it limits its knowledge to what it would “actually know” if it was a player and adjust itself only as such. If it scouts out fixed defences, then it might raise the priority on units tagged “artillery”, or if it finds lots of aircraft, it would do the same for “air defence”.
This system can have a lot of weighting influences – for example, how “heavy” a force should be (armour vs mobility), how rugged or urban the terrain is can influence unit choice, etc. – and weighting can be negative as well as positive! Weighting also, of course, applies to buildings as well as units, although in some cases there might be “overrides” – hard-set minimum or maximum weightings, which would serve to prevent the AI from building no builders or factories, or to limit the building of heavy units.
Indeed, in some cases like builders, there might be progressive weighting based on build numbers – so the first two or three builders might have a dramatically higher weighting! Another example is time-based weighting – early raider units might see their weighting initially be high, but then drop to a low/zero value after several minutes of play. More generally. you could even use tags for “phases” of play – early/mid/late game and let the AI decide when it’s in them, or weightings based on tech trees (i.e. you stop building tech 1 radars when you can build tech 2’s!).
The possibilities here are dazzling, to the degree that one must be careful not to become over-complex. There is also, however, one more important concept – unit grouping. When units work well together in a combined-arms situation, the AI may need to know in what proportions to build them once it starts doing so – in this case, they would be tagged as a group (and the group itself have tags)
An example might be– Light Artillery – “Artillery (1.5/tier1 (early), 0.5/T2 (late)), Group 3 (“light artillery”)(weight 4)” Other tags – Long Range, Light Ground Vehicle, Slow, Bombardment Strategy
(G3 being light arty and some anti-aircraft (weighted 1) and defence units (weighted 1)!)
A similar concept could use, for bases, templates (fixed layouts of buildings, i.e. a defence cluster) – which will be discussed in part 4. The key here is that usage of this should be limited (the entire template would have tags and a weight), as unlike groups of units, having repeated identical clusters of base templates is rather obvious as “AI play”.
Third party units should be able to plug into this system quite easily, if people pay the proper attention to tags and weighting. If nothing is defined, a small base weight could be given, but units should define their own weightings – there’s always a chance that units or buildings will be over-weighted by novice designers, but there is both little which can be done about that other than allowing designers to gain experience, and in many cases people will want to see their added units frequently anyway! Some kind of maximum weighting might be tried, but would probably be counter-productive.
Finally, we can consider the fact that the AI might have pre-chosen biases. In some RTS games, you can pick the “bias” of an AI for aggression or strategy when you set them up before the game, and the metadata system is an ideal way of doing this, applying global weightings! In other games, there might be a randomly chosen bias at game start, if you need to commit to a given strategy – other games might simply not do this, though, it is purely a refinement.
Aside from this unit-level control, maps also have a role to play. As well as the possibility of map specific AI’s, maps themselves could override for normal AI’s the weightings for certain types of unit, or indeed even ban certain units or tag weightings as unhelpful on that specific map.
Maps could also define areas or zones, either generally or for specific starting locations. For example, a hill might define a zone a top which is weighted “artillery”, and if it is close to the AI’s position then the AI will “know” it should place more artillery (and place it there). A canyon might be weighted “defence” at one end, etc. – this can make the AI make more “obvious” decisions which a Human could immediately see as beneficial, although over-use could make the AI predictable.
These zones could either be absolute (i.e. “within this area, weight x”) or from a point or area and the weighting drops off with range. If they are active or not for an AI could be tied into range, or some kind of land control system. In fact, let’s discuss one of those.
Let’s divide the map into equal segments, and tell the AI that it wants to try and occupy one segment at a time. The AI then fights evenly across all it’s boundaries…which isn’t ideal. Now, if we adjust the size of the segments, to have big segments in “empty”/low value areas, and smaller segments in chokepoints or resource clusters, the AI “knows” that those areas are more valuable. It also gives an AI a good idea of where it’s “borders” are, how important they are and so on – a useful aid for guiding an AI.
All these are, though, purely designer-level tools and not the core of the AI. It’s still important to have a good AI programmer, and to refine and test the AI, which should be working early in the project. Getting the AI going with some basic units and greybox art lets you build it alongside the gameplay rather than – as seems to be the case in many games – be tacked on at the end as an afterthought!
It’s also, absolutely, not an exhaustive list of tools, and the end goal should be kept in mind tools – the idea is to allow the AI to adjust and adapt and give a challenge without becoming deterministic. Some degree of brute-force AI cheating on resource and build time might be needed for the harder AI settings, but this should be kept to a minimum.
I hope this article has given you some ideas as to how an RTS game might handle building a better AI. You can’t stop the AI being “dumb”, but can help reduce outright “why did it do that” moments, without the AI being boringly predictable or obviously brute-force cheating!