3.08.2010

Programming an AI

AI programming in video games is always a curious endeavor. Really, it takes an expert at both playing and designing the game to make a competent AI when it faces human foes.

Many games lately have provided good and bad examples of how to program an AI, but the key to making an outstanding AI is making one that is unpredictable and that can "formulate" strategies based on what's going on. This usually involves layers and layers of logic and it's up to the programmer to decide how deep those layers should go.

For example, in Super Smash Bros Brawl, their AI is ridiculously good. The game plays fast enough as it is, and as a rule you can't make AI that reacts perfectly to everything going on otherwise people will hate playing against it. But often times, fighting the AI in Super Smash Bros feels almost exactly like fighting against a human.. play long enough and you won't be able to tell the difference. However, on the scoreboard, veterans of the game can beat a computer 9 times out of 10, on the hardest difficulty, so something is still missing.

Unfortunately, we still haven't seen a FPS where the AI can strategize and beat you based on strategy and execution, rather than a simple damage and health boost. Games like Shadowrun, Red Faction 2, Perfect Dark and ET: Quake Wars show you that you can fill human slots with bots and play a large-scale multiplayer match by yourself, if you wanted to. The downside was usually due to the bots' level of predictability - if they can see you, they'll shoot you. I'm wondering if the bots' level of predictability is either due to the complexity of the game, the fact that the developers don't always play and love their own games, or the fact that they just don't care about having a human-like bot in a shooter game.

It can be done in a shooter, and I'm wondering when we'll see the first time you'll start mistaking bots as humans if you're a veteran of the game. The way you'd need to implement it is by studying the way a human plays the game and assigning a loose strategy to a bot based on strategies you see coming up in human vs human matches. The strategies could be based on camping, shooting well from long range, being aggressive or reserved, setting traps, or occasionally programming something in where the bot can make a decision that is an obvious mistake, only because humans consistently make mistakes.. things like killing themselves by "accident", picking up two different weapons that don't mix well, or not seeing an enemy on a radar. Or, for that matter, not being able to tell where they're shot from!

It's so interesting the kinds of things you could observe when a human is playing a video game. Difficulty could be set up by a multiplier, increasing the chances that they won't make mistakes or that they'll land their shots on a moving target (actually, the 2nd one has already been done). The outcome of an AI starts on the design level, though. The designer would have to determine good and bad strategies and then convey to the programming team to build an AI structure where all of the low probabilities indicate a bad decision, and all of the high probabilities indicate a good decision, for the sake of consistency. The programming team would also have to accept that the design for the AI would have to constantly change as new issues arose in testing, so it may take a design and programming specialist to really pull this off.

Reaction time would also be another interesting thing to program.. make the AI wait when a trigger is set off before making a decision, just like a human does, or try to anticipate what a human will do based on typical human behavior. I've also never seen a bot deliberately run away from a fight, either.

Jeez.. there's so many things that could go into programming an AI in a game, it's really ridiculous when you think about it. I'm currently programming AI for a game I'm working on and I'm wondering what level of intricacy I should write. It'd be nice to play a game where it felt like you were playing a bunch of other humans instead of predictable AI that you can either treat very aggressively or predict based on their behavior. Although, writing that kind of AI would take a long time, especially when it came down to testing, and I'm not sure it'd be appreciated for what it actually was if I did make it as complex as possible, and it worked the way I wanted it to.

I guess we'll see, eh?

1 comment:

  1. Hmmm, this seemed very aimed at FPS AI and the problem with FPS AI, really isn't that they can't strategize, because if you pay attention they really do it quit well. The biggest problem is the way they move. Seriously when you watch a bot run around, not even fight, just run around a level, then watch a human do the same thing, it's amazing the difference. One of the biggest problems is that humans see shortcuts, we see where we can jump to cut time, we see cover as more then a node that says I can hide here, we see an open area as an open area. Making a bot that can move like a person in a game such as halo where players make very intricate moves is something that's rediculously hard. The third dimension with AI is one of the hardest things to deal with.

    ReplyDelete