Wow. A dude by the name of Shamus Young wrote a great column on the AI of Starcraft on his blog, Twenty-Sided. In fact, it would be worth of a Post-Play’em entry and I almost toyed with writing this post over there. Anyway, he wrote a script that allows 7 AI players to battle it out with the 8th slot being left for the player to control no units but observe the entire map. Often, he would let the game run overnight and see what had transpired come morning. His observations were rather interesting and served to do two things:
- Point out the various strengths and weaknesses of the different races
- Point out that the AI is largely a rule-based engine with not a lot of forethought, planning or strategic processing… and definitely no learning capabilities.
While, as always, I encourage you to read his article at his blog, I do want to break down a couple of his observations here.
At first I just set the difficulty to “normal”, but I found that the computer players were far too likely to consume all the resources on the map, go broke, and then just sit there. I’d start a game before going to bed, and when I came back in the morning I’d find the battle was down to three sides who couldn’t make any fighting units. I changed the difficulty to “Insane”, which auto-cheats by giving itself 2,000 minerals and gas anytime it goes broke, meaning the thing is always rolling in resources.
It is my opinion that this is a major failing of the game. He points out that on the “insane” difficulty level the AI just simply gives itself more resources if it runs out. Because of that, there is no “end game” scenario that the computer has to plan for. There is no timer ticking down for it. However, there certainly is for the player. You need to make your move before your resources go dry. However, the computer is still playing “as if” the resources are still important. Shamus goes on…
I dislike this auto-cheat for a number of reasons, mostly because it negates a lot of the strategy in the game. None of the players can go broke, but the AI still plays as though resources were important. The only true way to knock a player out of the game is to annihilate their core base with all the critical buildings in it. Expansion bases are (mostly) worthless in a game like this. Yet the computer still builds and defends expansions (because that’s what it’s programmed to do) and still wastes time attacking enemy expansion bases. This introduces a bit of luck into the game: Who wins depends a lot on positioning. The AI tends to attack the nearest base, not the most important one. Sometimes the nearest base is the core base. Sometimes the nearest is an expansion which is pointlessly destroyed and rebuilt over and over again.
Now, that may be by design. I don’t know. From a mentality standpoint, the idea could be not to secure an expansion in order to secure the resources for yourself but rather to keep them from the player(s). That certainly makes sense. I doubt, however, that was the case. It is likely that the 2000 rule was simply a cheat to make things miserable for the player. *shrug* It’s an RTS staple, I suppose.
Moving on, the next section reeks of a scripted build order.
Without the unpredictable actions of a human involved in the match, the AI fights like clockwork. Games have a perceptible rhythm to them. They all build their first couple of buildings within a few seconds of each other. Even these variations are probably the result of minor changes in the layout of each base. If the bases were somehow shaped the same, the players would probably all build in perfect unison.
They build an initial attack force. On insane difficulty this attack force is huge – probably sixteen or so zealots or the given race equivalent. On normal difficulty the force is smaller, but the behavior is the same. They all leave the base at about the same time, and (as far as I can tell) attack a foe totally at random.
That means there may be some sort of rule-based system in place. Age Of Empires/Kings did this exact same thing. All the AIs would seem like they were working in sync, but that was because there all had the same timer settings (i.e. “If Timer = 1500, launch attack”).
For the most part, I can understand doing it this way. Short of putting together some sort of GOAP system in place to sequence individual actions into a cohesive plan, the only thing left would be a random build order… which would start to look silly. One thing that he didn’t mention here is if the build order was always the same… especially in the middle phases. It would be nice to see that the computer doesn’t play an individual race the same way every time. That would be something that, right out of the gate, would start to mix things up a bit.
The interesting bit is “attack a foe at random”. I would say that is, again, just a simplicity cheat. It would be a little mathematically intensive to process it further. However, there may be something not accounted for here. Since all the AIs are in sync at that point of the game, if there IS a mathematical scoring system, they would all come out the same. Therefore, in case of ties, taking “the top of the list” may tend to look random. The obvious fix that was missing, though, is a proximity factor. This helps in two ways:
- It’s quicker and more manageable to wage war with a foe that is nearby
- It’s easier to recall forces into a defensive perimeter when your they aren’t across the map
Shamus touches on this:
Nobody has any defenses at this point, so when an enemy comes knocking, their survival is a matter of luck: The defender has an attack force elsewhere on the
map. Is that force still intact, and can it be recalled before the place is destroyed? Are there enough of them left to save the place?
Another artifact of this “shoot anything that moves” strategy is that the AI is truly engaging all 6 of the opponents at all times rather than focusing on one or two of the most threatening (by strength or proximity).
A player can also do really well if they are attacked by two people at exactly the same time – the attackers end up wiping each other out and leaving the buildings alone.
As he notes, that turns messy and wasteful when attacking an enemy. Sure, when defending your own areas, you will want to repel anyone that comes near, however, if you are across the map attacking a base, don’t waste time with the other forces that happen to be in the area unless they attack you as well. Really, this could be handled rather well with an influence map that is laid down spreading from your buildings to determine whether you are in a “defensive” zone or not. If you are, attack anyone that comes in. If not, stick to the plan.
The AI seems to wait until this initial attack force is nearly all dead before entering the next phase: It builds defenses and another attack force. Again, this force is sent out. Once gone, the AI begins trying to build its first expansion base.
The rest of the game is a series of escalating attack waves. As they add more buildings onto their main base they work their way up to air units,
More evidence of a strictly scripted/rule-based system. There are obvious triggers here. If this is truly the case, this method could fall on its face in a number of ways.
For example, if the AI’s attack force survives a battle with just enough units to NOT trigger the next build, but the force it defeated is now in the next build (because their unit count dropped below the threshold), the AI actually starts to fall behind. An exploit would be to NOT kill the AI’s units off but just run them around the map for a while. You can build at will, but the AI is still waiting for the trigger to happen.
One interesting point that he made was regarding the difference in how the AI uses Protoss Templars vs. a human compared to vs. another AI. Check this out…
When I fight the AI Protoss, it uses the Templar Psi Storm with murderous efficiency. I’ll have a tight group of units moving into its base when a Templar will appear in juuuust the right spot, drop a Psi Storm on my guys, and dart away before I can punish him for it. With a couple of Templar available he’ll play hit-and-run with me all day, and do tremendous, infuriating damage to my forces.
Against other AI, the Templar are bumbling comic goofs. They will drop Psi Storm on single enemy units and hit a bunch of their own guys in the process. They will blunder through fortified territory attempting to reach a unit deep inside, and get cut down before they even get close.
I’ve come to suspect that the AI cheats a bit and detects clusters of units which have been grouped by hotkey by human players. This is very naughty if it’s true. What’s worse is that peeking at how my hotkeys are set up seems to be central to its decision making. Deprived of that bit of cheating info, the Templar is helplessly stupid. Boo. (empahsis mine)
Now THAT is interesting. Rather than write up some sort of grouping algorithm or process a very dynamic influence map, use something that the human player is going to likely use. If he doesn’t use hot keys on his groups, he’s a n00b anyway and could stand the help of an ineffectual AI. It would be interesting to try and play without hot-keying your forces and see if the AI Protoss can use those Templars effectively or not.
His complaints about how poor the AI is at playing Terrans are well-founded:
I’m note sure why the thing is so bad at utilizing Terrans. Aside from the issues I mention above, it just seems less aggressive overall. It also has a penchant for building base defenses (bunkers, towers) in places where a base should go, effectively rendering a viable expansion useless. It will attempt to lunch nukes without bothering to cloak the Ghost first. It will risk the painfully expensive Science Vessel in order to irradiate something of very low strategic value. It makes small numbers of all units instead of focusing on a few and using them well.
All of the above could be solved with some mathematical analysis of the units, the situations, the terrain, etc. It’s a shame that wasn’t done.
Now… keep in mind, this game was made 10 years ago. RTS AI was stagnant for the most part during that period. Age of Empires and Age of Kings had horribly inconsistent AI as well. It is my (less than perfect knowledge) opinion that RTS AI didn’t turn the corner until Empire Earth (Stainless Steel Studios) in 2001.
Anyway, Shamus’ project is fantastic and his analysis was very pleasant to read. I may have to find my Starcraft CD so I can download the zip file. I would be very interested to watch through these games and see what else I could see.