As more women than ever before begin to find themselves interested in video games, it’s likely that many women are also wondering, “What is it that makes games think?” For many games, from adventure and role playing genres to challenges like chess, game developers need to incorporate techniques that allow help a computer to think for itself in a timely fashion. Some of these techniques will be revealed below as light is shed on what gives games brains.
First, let’s reflect on why having good artificial intelligence (also known simply as AI) can be so important for a game to be fun. Many board games and first person shooters can’t be played without an actual opponent, but a human contender is not always available. This makes providing an opponent controlled by AI an important option. Adventure and role playing games don’t usually involve a real opponent, but there are always bad guys that have to fight back realistically. Make them too hard, and the player will die too often. Make them too easy, and you take away all the challenge. In sports games, announcers have to make sense when describing the plays you make. Choppy or confusing voice-overs would take a lot away from the realistic nature of the simulation. Even with these few examples, it’s already clear how important AI can be in making a game more realistic and more entertaining.
How does a computer – which can do calculations and perform basic instructions really really fast but can’t do anything we don’t tell it to – think? Well, it can’t. It can only simulate the kind of intelligence we possess as humans. In games, the basic steps to looking smart are:
1. Sense what’s happening in the game.
2. Decide the best course of action based on the information available.
3. Perform the best action.
After the state of everything happening in a game is put together for examination, it can be used to figure out what action could be taken so the game appears intelligent. It’s this second step that we’ll talk about here, looking at some different ways to make this decision.
Let’s see how this is applied to the game of checkers, where we are playing a computer opponent. We’ll say that we just made a move and the computer must decide what it should do next. The first step is to sense what the current state of the game is. In checkers, this means looking at each square on the board to see if there is a black or white checker on it, or none at all. Now the computer knows what moves are available to it, based on the rules of checkers. Pretending to take each one of those moves, the computer then branches out and checks what moves are available next. It can repeat this several times before times or memory runs out. After looking through these scenarios, the computer can use some form of evaluation (given to it by the programmer, of course) to decide which outcome would be the best. The more scenarios the computer has time to look through, the more likely it can choose a path that will allow it to win. This strategy is known as “state based search” and was used to help IBM’s Deep Blue beat a reigning world chess champion.
For games that have to manage autonomous enemies or friendly characters, state based search doesn’t quite sound like the right solution. Instead, something called a finite state machine might be used for adventure, shooter, or role playing games. This structure has ‘islands’ that represent various states that a character might be in. For example, one island might represent the ‘asleep’ state, another the ‘fighting’ state, and another still the ‘wandering’ state. Then there are ‘shipping channels’ set up between the islands, but you can only get on a particular ship when a certain event happens. So let’s say that an enemy is currently in the wandering state, and after sensing that you, the hero, have become close to him, the shipping channel from the wandering state to the fighting state is opened up. Now the enemy ‘changes islands’ and ends up in the fighting state until something allows him to leave it. While in that state, the actions he takes will be predefined for the fighting state. In this way, the decisions that a particular character can make after sensing the state of the game are coded into this islands and shipping lanes map.
Those are just a couple of ways to add a bit of intelligence to video games these days. You can learn about these two and more at such sites as The Game AI Page, AIGameDev.com, and Game/AI. If it turns out you’re interested in this, there’s still lots more to figure out so it’s a worthwhile subject to learn about in school!