Making enemies move and shoot: An A.I. Primer part 1

Okay, so after I read the conversation on A.I. between Jay and Christian, I started coming up with comments. Then I re-organized them, and kept coming up with more. Well before I felt I had addressed things enough to post a comment, I had the makings of a brief paper on A.I. as it applies to video games. That was when I spoke with Jay about just writing it up as an article instead of posting a several-page comment, and he said to give it a shot.

Unfortunately I tend to go a little nuts when A.I. is concerned, and so it’s now turned into what’s possibly a multiple installment piece. In this first bit, what I want to cover are the uses to which we put A.I. for video games. They break down nicely into three main categories: uses related to gameplay and mechanics, A.I. that contributes to then immersive experience of the game, and A.I. used for aesthetic reasons.

A.I. is generally divided into two schools of thought. Conventional A.I. involves rule and probability-based systems and representational reasoning, and is the type of A.I. most often applied to games. Computational Intelligence involves non-symbolic reasoning, neural networks and fuzzy logic, and is far less often applied to games, both due to its less-predictable nature and its higher resource requirements. For the purposes of this article, however, either school of thought could be turned toward the ends discussed below.

These are the wrong kind of bots, but they sure are cool.

A.I. in the broadest sense is any attempt to make computers imitate the actions taken by an intelligent being. As it applies to video games, it’s any attempt to allow you to play with or against something without requiring a real person directing its movements. For the rest of my ramblings, I’m going to call any of these things in a game that either plays with, against, or just somewhere near you bots, because it was really hard to write about them calling them something different in every game/situation.

The first reason why we create bots should be obvious. We need them for basic game mechanics and gameplay functionality. This area of A.I. is often either overlooked or viewed from an overly-simplified view. It is not just the science of making enemies kill more effectively, although for a long time that was a major challenge.

From the basics like pathfinding, aiming, and simple movement patterns to modeling senses and detection for a stealth game, it is important to the mechanics of almost any game that the player have opponents to play against. Pac-man isn’t any fun without the ghosts, and a game of pong with only one paddle gets boring really quickly. The same goes for a FPS without enemies or an RPG where you’re literally the only creature in the whole world. Even puzzle games often employ rudimentary A.I. to select the next pieces and keep the game playable, or to allow you to do a one-on-one challenge against the computer.

Keep in mind that A.I. in this context does not mean the machine has to learn or adapt, simply that it has to in some way mimic even very repetitive human activity. A.I. is used for gameplay and mechanics even in games that appear on the surface to be based purely on pattern memorization, such as shooters or old-school platformers like Super Mario Brothers. When an enemy flies towards the player’s ship, or hovers in front of it and moves back and forth, that employs a simple but appropriate form of A.I. The same applies to the hammer brothers that jump around and toss hammers, or the chomps that sense your presence and lunge at you.

Games are not much fun when you’re all alone.

The next application of A.I. is in enhancing immersion. The line between immersion and game mechanics can be a blurry one, since most immersion is achieved through shifts in game mechanics. At some point, however, you reach behaviors whose purpose is not to balance the difficulty of the game or contribute to the underlying gameplay mechanism, but which instead exist to help the game world make more sense to the player – whether it is noticed or not.

The human mind works through categorization and prediction. When something happens that we do not understand and cannot categorize, we are jarred from the suspension of disbelief. Therefore the best way to preserve this suspension is to make all the bots act in a way which makes sense to the user. The best way to do this is to have the bots act from an understandable perspective that makes sense within the framework of the game world. Just as in movies, we will believe the impossible and accept it as an axiom of the world we are facing, but when faced with the improbable or confusing, we loose our ability to suspend disbelief.

For instance, a bot in a stealth-related game not noticing me because he is facing away or is distracted makes more sense than a bot not noticing me simply because I have a high stealth rating, even when they are staring straight at me and I’m in broad daylight. Similarly, when approaching an enemy if it is seen to hear a sound and then turn, rather than just suddenly becoming aware, it fits a known pattern from the real world, which in turn improves immersion. Even having a shopkeeper remember a player, or greet them with slightly different language each time a conversation was begun helps immensely.

Notify of

Inline Feedbacks
View all comments
18 years ago

A fine article right here, with a couple of fields I never considered to think about. Can’t wait for the next part.

One of the interesting things I was reading about in my own research into game ai is why the field is so much less advanced than it could be. It seems to be a combination of

a)Developers not wanting to “waste” CPU cycles that could go into rednering for something like AI routines. Shiny graphics sell games

b)Developers seem to cling to certain technologies rather than play around with something new. Half Life 1 used a version of the A* algorithm for pathfinding, yet it seems to be that people are still using it to this day. Black and White tried to experiment with a basic form of machine learning, but the concept has been pretty much abandoned. There are a lot of great AI techniques being developed in academia, but it seems to take a very long while for them to find their way into games. I’ll never forget the one research paper I read in which a professor used finite state machines and rule based systems in order to produce a very good bot for Quake 2. He ran his bot on a separate, junky old computer that communicated with the game over sockets. If this can be done with such old hardware, then there is no reason why it can’t be done on modern equipment (that is, unless you really need to implement that ray tracer…).

18 years ago

I agree, it seems to fall by the wayside very often. Honestly when playing FPS deathmatch-type games, I don’t get the impression that enemeies are really much more advanced than reaper bots were back in the day. If you ever look at the code for the quake 1 reaper bots, it’s really pretty simple, and ran fine on an old 486 – leaving massive amounts of processing power free on today’s machines. But instead of using it, we continue with simple state searches and branching conversation trees.

I think for the most part it’s not technical limitations so much as lack of interest on the part of developers, but that’s something I should probably save for the next couple articles :)

18 years ago

I look forward to it!