AI At The Next Level - Zoning

Total Annihilation was a totally new game in so many ways, the most noted aspect is the way in which almost anything can be changed. Customization is very popular in First Person Perspective (FPS) games, but not something so common among Real Time Strategy (RTS). This game [Total Annihilation] won praise for its terrain, orders, units and the number of them. Finally the AI was praised for being aggressive.

However, it wasn't long before people starting spotting patterns in the AI's behavior. It was very vulnerable to early attack, could see "everything," and would always head for the nearest target. Cavedog could improve the AI to a limited extent, but to fix the major "always attacks nearest target" limitation would take a major engine rewrite, and often they made the situation worse, just go back to the original and watch how an AI Commander reacts to your attacks on his base, then play 3.1 and see that all he does now is wiggle.

There has not been an RTS released to date that has shipped with an AI that could be called challenging for anyone above, or even rated as, average. In FPS, AI has become a major marketing feature, but for now this has passed RTS by as people seem content with fairly feeble foes. The best the RTS genre can offer are AI's from games like Krush Kill 'N' Destroy 2, and Seven Kingdoms II. Both of these AI's have limitations. KKnD2 will follow a set build pattern making it very predictable early on, SKII lets it's troops turn into stringy columns and is too vulnerable to spies.

This article aims to lay down the basis for a new system of AI, a simple look at how AI could be improved without delving into the coding side of things.

Zoning Introduction

Zoning began as a simple idea I had when someone on the Cavedog forum was inquiring into tougher AI's. I had been toying with some ways to improve AI in a genre that seemed to suffer a chronic shortage of smart ones. This soon became a fully fledged post of it's own, and advanced with ideas and support from other members of the board until it became a very advanced AI concept.

Of course, this is in an era when Cavedog never checked back on its boards, so the main elements of the discussion have been recorded here at AI Central for posterity and can be found in the Zoning Discussion article.

AI Problems Laid Bare

The main problem with AI's currently is overall understanding. Telling an AI how to best handle a unit is not as hard as trying to make an AI understand what everything counts for in the greater scheme of things. The AI knows when it can attack, but it never thinks where, when and why. Often it will amass a large army, only to throw it through a valley where the additional firepower counts for nothing simply because the units move through one at a time.

Secondly, a TA AI has to cope with something that no other AI has had to before. Building positions. AI's have been able to get away with feeble decision making for a long time, simply because the enemy was always clumped in one position and wasn't going anywhere. It was a simple matter of ordering the troops there. In TA this changed, buildings could be put wherever the player desired to out them. Now while this was an excellent features for players, for the AI it was a nightmare and an issue that seems not to have been thought of, and certainly not addressed.

Thirdly, very few AI's will use more than one group of troops at a time, and most of those that do, do so through accident and loose ties with the main group. Only KKnD2 truly understands how to handle multiple groups. Actually Kingdoms adds the ability for the AI to have more than one group, though because it is so feeble it just ends up over extending itself by attacking on multiple fronts. Most games will simply try to steamroll you with an ever growing number of troops. This has some basic flaws:

You can position a few troops around the back of the main AI group and pick off the reinforcements one by one. Eventually the main group will be starved of additional troops to replace the ones it's lost, and will die.

The AI will constantly overkill. Many buildings require just a couple of units to destroy them, not an entire army. Because of this the AI is often using far more force at certain points than is needed and gives the player breathing room they shouldn't have.

An AI army can be lead on a wild goose chase by small bases, or even single units. This can mean the main (in fact the only) thrust of the AI is going the wrong way.

Zoning Outline

The initial idea was to divide the map into squares of undetermined size. Each square contains data on terrain, weapons, troops and so forth. Each square then is put into one of four categories:

The AI then understands the concept of territory, where it is safe to move, where escorts are required, and where an attacking force should be deployed. But this is a fairly general system, and does not solve a lot of the problems. But it does allow for the AI to deploy defence in the correct place, giving preference to a Friendly Zone which borders on No Mans Land, and allowing it to abandon areas which have been cut off as these are costly to take back.

The AI would be able to send troops to Disputed Zones, dividing these troops between the zones them depending on the number of enemy units involved and the rewards gained from the Zone, such as is it a high metal area?

Advancing The Concept

Of course, dealing simply in the concept of the number of units involved is fairly primitive, after all in TA a Sumo would easily eat five Flash tanks, so sending five Flashes to stop a Sumo won't work, and five Sumos to stop a Flash is overkill, and can end up simply eating it's dust.

This means that the AI needs to know what a unit can do. Again this is best done through categories. Units under a certain speed and with a certain weapon power (read Sumos and Goliath's) become base busters, units with high range are employed as structure destroyers, while fast units are employed separately in small groups as raiders and fast response units.

This allows the AI greater flexibility. Heavy troops can clear out bases, while long ranges ones deal with defensive hardpoints. Fast units assist where needed, helping in Disputed Zones, defending the borders of the AI's territory and the escorting of civilian type units, be it a Red Alert Ore Truck, or a Total Annihilation Construction unit.

Enemy Zones would need to split into various types, such as Resource and Defence Zones. This then allows the AI to choose a large resource target, while trying to make minimal contact with enemy defences. To take this further it could analyze what troops it had available, and then plot a course which took it past defences these troops were best suited to dealing with, or avoiding. An example would be light units like the Flash could move without too much difficulty through Zones defended by Guardians.

Strategy

The AI needs to understand what it should be doing with these Zones, it has a Friendly Zone, but what does that mean to it?

The AI would use these Zones to understand proper attack, defence and building placement. For example, when it has decided to place a Fusion, it would go through its Friendly Zones, comparing how far away each was from the Disputed and Enemy Zones, how much defence was in the Zone and also how many Zones the construction unit would have to travel to get there. Plus you don't want to put the Fusion next to every other Fusion, so the AI may have a limit of one Fusion per Zone. Moving through a non-friendly Zone would be a last resort. With this kind of information available to the AI it could make an intelligent decision to do with placement. It would be able to put a valuable unit in a highly protected area, while if the Fusion was required immediately, it could look for somewhere close by that met the defence requirements.

Heavy Assault

A human will usually fight on many different fronts, trying to find a weakspot in their opponents defences. An AI should also aim for weakpoints, but it should also then aim for valuable structures once through, rather than wandering around the border trying to tackle every defensive structure in existence.

Firstly we split the Enemy Zone in two, becoming, Defence Zone and Resource Zone. A Defence Zone is usually found on a border. It will contain walls and defensive weapons. A Resource Zone will have items essential to the running of the war effort in them. The less defence the better.

A Resource Zone sits behind the main lines, it will contain something like a Fusion, MEX or large collection of Solars.

An AI can now plan its assault. The objective of any attack is to cripple the enemies resource machine so as to make them much easier to wipe out. The AI should plan an assault route which takes it through the minimal Defence Zones and into the most Resource Zones possible. Now add in some basic weapon understanding. The AI should realize the average amount of damage it will take per second in a Zone, and thus try to take a route which minimizes the damage, and maximizes the number of resources hit, by working out how much is produced in each Resource Zone.

This of course does not allow for defence and resources to be together in a Zone in large numbers.

The AI will really need to calculate the fire ranges of each defence either in accurate ranges or in terms of Zones. This allows it to plot a course around heavy fire. If the attack consisted of heavy units then enemy energy should be given preference, and with lighter fast units, Metal Extractors should be the target of the day, but that is Light Assault.

If the AI should breach your outer defences and reach a resource zone, then it could immediately deploy any small but fast groups to go in and maximize damage while the heavier units deal with any nearby threats, actively targeting resources when there is nothing else to do.

Light Assault

Another category useful to an AI is one which allows it to gather small numbers of fast troops. These will be deployed to hit the most vulnerable Metal Extractors, those which have open routes to them, with minimal defence in the area.

If the AI decides that enough outlying resources have been hit, say if the entire outer ring is entirely defence with no outlying Metal Extractors, then the AI could try to flood a weak point in the defences, simply by charging a large number of cheap units though. Once through, the AI will divide these into small packs sending them off to hit Metal Extractors.

If these groups should come under heavy fire, or start taking casualties, then they would break off and either select a new target, or if need be pick up an extra unit or two back at base, or get these units sent along to back them up.

Conclusions

Just by using these simple concepts of Zones you have an AI which can play a much more human game, choosing troops for tasks they are suited to, avoiding defences while trying to strike at resources, moving to defend its own resources and making intelligent placement decisions for buildings.

It doesn't seem like much does it? Simply dividing the map into hexagons. Yet by doing this, you immediately give the AI a way of analyzing the battlefield at a much more detailed level. This allows the AI to have a greater understanding of what is happening, make more intelligent decisions, and thus seem more human, or at the very least tougher.

If you think I've missed anything, or have any points you wish clarifying, please contact me.

- Quitch