The Trick to Gaming AI - Faking Intelligence
One of the things I really enjoy reading about is artificial intelligence. Not just the academic version, with it’s pursuit of mimicking real life and creating a true ‘thinking AI’, but the gaming version too. Here, the aim is completely different - simply make the game enjoyable. As this is the ultimate aim, AI programmers will get up to all sorts of tricks to achieve it. And they have to, for the pressure is high - make it too stupid and the game looks shoddy, make it too difficult and it’s no fun to play.
Sometimes the AI can be easy to do, sometimes not. Fighting games, for example, are rather simple affairs from an AI point of view, so they don’t need much - normally just a decision tree based on each other’s health and some other factors. On the other hand, AI in strategy games become rather complex very quickly. There’s so much to keep track of - resource management, tech queues, inter-squad strategies, real-time pathfinding for every unit on the map, etc. No wonder AI programmers will use tricks and short-cuts to fake intelligence and cut down on CPU cycles.
I was reminded of this when I read Shamus Young’s post Starcraft: Bot Fight. In it, he looks at the AI of Starcraft: Brood Wars via a series of skirmish matches. When he analysed the matches he found that the AI was rather weak when fighting each other, but was far stronger when fighting him. The reason - the AI had access to the player’s information, such as hot-keys and troop movements. Much easier than doing it the ‘proper’ way.
Another game with AI tricks is F.E.A.R. Looking at a review of the AI, one thing stands out: it does a whole bag of cool things to enable the AI to mainly move from cover to cover. Is that soldier flanking you? Well, yeah - the level design made sure there was pieces of cover to guide him there. Are those soldiers regrouping? Yeah, to behind some cover. Where is that soldier running to? Oh, some cover. Don’t believe me? Here’s an excerpt from Gamespy’s article F.E.A.R.’s AI Demystified:
F.E.A.R. was widely lauded for the ability of its soldiers (both singly and in squads) to flank the player. In reality, the AI wasn’t flanking at all — it was moving from one cover area to another cover area. Because of the skill exhibited by the level designers, that next cover area was to the side of the player’s location (or where the designers assumed the player would be), so when the AI moved to that location, it created a seamless illusion of the enemy flanking you.
Does this mean that game AI programmers are lazy? No. The priorities are just different. Why waste time coding complex resource management routines when you can give the computer player free cash whenever it needs it? You can then focus on other things, like tracking a human player’s units (even ones you can’t see) and ambushing isolated ones, thus appearing more intelligent. Not only that, it allows you to free up CPU time for other things.
In fact, game AI programmers shouldn’t be afraid to take shortcuts. Remember, the end result is to make a game fun, not ‘real’.
Posted in Coding