IA Logo


IA Information
Communication

Dave Mark's books

IA on AI


Starcraft AI Exposed Through a "Bot Flight"

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:

  1. Point out the various strengths and weaknesses of the different races
  2. 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.

Tags: , , , , , , , , , ,



6 Responses to “Starcraft AI Exposed Through a "Bot Flight"”

  1. Andy says:

    You really should read the comments, I mean, I commented on Shamus’ writeup – the fact is, he should have done some research on the net, and found out a lot of the AI limitations that way (such as, basically, it’s all C++ engine coded for the “intelligence” and the only variable is the build order basically).

    That, and the “Grouping” thing is a load of rubbish, certainly not an informed analysis if he can’t do a bit of back reading, especially for a 10 year old game.

    But cest la vie, he did writeup something about a well planned game at least, even if the AI in that game isn’t the best.

  2. Dave Mark says:

    Admitedly, I didn’t read all… what, 60?… comments on the article. I thought the hot key thing may be out there a bit, although I’m privy to plenty of other cheats that are just as contrived.

    Your point about the AI limitations is dead on. Starcraft is no exception. Even today, RTS AI is a little rough at times. When you have an intelligent agent that lasts as long as an RTS player does (compared to an FPS enemy, for example), some weaknesses are going to get exposed.

    Thanks for dropping by and commenting!

  3. Andy says:

    I should do a writeup on much new RTS games – while some inherently fall down (and work in a more limited capacity then the player), some don’t as much. Supreme Commander supposedly has all the player’s own interfaces available, and the code simply gets information from the game (similar to the player’s information available) then decide what to do with it. Dawn of War works in a slightly similar way, and both games now deal with FOW to a degree.

    More interesting might be World in Conflict, which has respawning troops and more “FPS” like objectives in skirmish scenarios – the campaign AI is scripted, but the skirmish AI seems competent and sometimes brutal (and no cheating it seems!)

    Come a long way since Starcraft. It’s perhaps a nice retrospective, but yeah, very very old.

  4. Anonymous says:

    —–BEGIN PGP SIGNED MESSAGE—–
    Hash: SHA512

    To whom It May Concern, your assessment of the Starcraft ai as of version
    1.15.2.1 are completely inaccurate. From what I have observed, the Zerg
    have yet to loose; usually one brood in the top most tire and the other in
    a much lower rank. However, the Terran remains the lowest ranking faction.
    Usually one Terran cpu is brutally wiped early on. There are other STRANGE
    things one can observe

    Zerglings stuck IN hatcheries.
    Randomly placed pylons on narrow paths.
    Sunken colonies creating Zerk bottle necks.
    Suicidal high templar (either rushing into an enemy base or committing
    suicide via psionic storm).
    Bases reduced to three buildings and one unit, then left alone for over 30
    mins, hell there was on incomplete Terran building left alone one time.
    The Terran hesitate to tech resulting in their slaughter (marines vs
    reavers anyone?).
    “Abandoned” units (one to three) left half way across the map (to stare
    at minerals usually) for a faction that is still active. I am going to call
    this the “lost reavers” syndrome.

    All available in these replays for your viewing pleasure!

    .RAR archive, 10% recovery record, includes file hashes or my PGP
    signature, Can’t open it get 7zip or winRAR

    http://myfreefilehosting.com/f/bdc175e9fd_0.25MB

    ENJOY!

    —–BEGIN PGP SIGNATURE—–
    Version: (N/A)
    Charset: utf-8

    wsFVAwUBSH2Vll7XhVEhLY/KAQrRxA/+MTHBj29UIC+TOl/zVgDsTkIc/UDq/koc
    VjjSVCnVsMdJfbcs86rEVy9SaX6EeQpfRRAEScN32HHntNO/6pSHWePqW1FANaMO
    INmcux8gxkg4gx1brwMCElPzPdW/fUXASB59SI/e4odakAcpkeQ3i7JyFQm9C7i+
    U2uX2VB9MO3ZuaVtZUdBHGTz71R1WBquk1Z7J0zNcaqmf8nB+OB9i30qQ0dRT2KP
    cV8bnBhSp+qMDlafMPQ5igi+UGSJS8mWnAY5s6VdbDjP9ujt/ESye0JZ4AY1OJoP
    fCmw3VYMOxil3Wov7ldHpB6tNy1yotvDab/Gl4dCpJbdrbl6RGWJgf5J2zkb4Cxn
    4SON2QiXGse428PnO4EDOI7yLZff+4HCfNarCKa/Slv0/8vwQDbtzjKGCFR2c9g2
    LK3mborvy77YnygiZvTk50cc8rHmZGv5dWDWZ1RHTFvcqXXgn6tpBF3DGErV5Eu2
    o8f1ERWIes5jvcJd9OZ9SYYnkwL2acPlgT/00ge1iztynHJN6BXekoULVz/H8nkG
    EeuAP5sIsdirqKWDrA9tlpy4WcpbxrFizEBd2QUp8e+0AWr49ZpnS8M6XA+Jqcow
    xohXeBbbsnbdKuXf9fICEEpQNVMJq91oT5iHCy/l5uT2pKGBYFoJSpauC/iafpAg
    6Ak+QwSl0ZI=
    =L0Pe
    —–END PGP SIGNATURE—–

  5. streetCat says:

    He didn’t have to run tests to figure all this out. After a bit of research online years ago, I figured out how to view the AI scripts in Starcraft. People even hold competitions for who can make the best ones. Yea…it’s not the best AI unfortunately…

  6. JoeRodge says:

    Been reading your blog for awhile now. We should link sites. I own a battle.net clan hosting site.

Leave a Reply

Add to Google Reader or Homepage

Latest blog posts:

IA News

IA on AI

Post-Play'em




Content ©2002-2010 by Intrinsic Algorithm L.L.C.

OGDA