Tricks of the Windows Game Programming Gurus:Making Silicon Think with Artificial Intelligence

All ITKnowledge Source Code Search Tips Advanced Search |

| Tricks of the Windows Game Programming Gurus by Andre LaMothe Sams, Macmillan Computer Publishing ISBN: 0672313618 Pub Date: 09/27/99

Search this book:

Previous | Table of Contents | Next

### Building Real AI for Games

That’s about all there is to the basic AI techniques used in games. I’ve shown you a few techniques to get you started, but you might not be totally sure about which techniques to use and how to mix different techniques to make new models. Here are some basic guidelines:

  • Use simple deterministic AIs for objects that have simple behaviors, like rocks, missiles, and so on.
  • For objects that are supposed to be smart but are part of the environment rather than the main action (such as birds that fly around or a space ship that flies by once), use deterministic AI coupled with patterns and a bit of randomness.
  • For your important game characters that interact with the player, you definitely need FSMs coupled with the other supporting techniques. However, some creatures don’t have to be as smart as others, such as the FSMs for your basic creatures, and they don’t need to have probability distributions for personality coupled with memory for learning.
  • Finally, the main character(s) in the game should be very smart. You should integrate everything together. The AI should be state-driven, with a lot of conditional logic, probability, and memory for controlling state transitions. In addition, the AI should be able to change from one state to another if conditions exist that make the change necessary (even if the state hasn’t come to completion).

You don’t need to go all out on a randomly moving rock, but for a tank that plays against the player, you should. A model that works well for me is an AI that has at its highest level a set of conditionals and probabilities that select states. The states emulate a number of behaviors, usually about 5-10. I like to use a memory to track key elements in the game and make better decisions. Also, I like to throw in random numbers in a lot of the decisions, even if they’re totally simple. This adds a little uncertainty to the AI.

Next, I definitely like to have scripted patterns available to create the illusion of complex thought. However, again I throw random events in the patterns themselves. For example, if my AI moved into a pattern state and selected a circle, fine. But sometimes as it’s doing the circle, it makes an egg shape! The point is, people aren’t perfect, and sometimes we make mistakes. This quality is very important in game AI, so coin-tossing helps to shake things up.

Finally, a very complex system can evolve from very simple constituents. In other words, even though the AI for each individual creature might not be that complex, their interaction will create an emergent behavioral system that seems to go beyond its programming. Just look at your own brain, where each cell is hardly aware of itself. It’s important to help facilitate this with some kind of sharing or merging of information between creatures, such as when they get close enough or at specific intervals. This helps with the sharing of “knowledge” in the simulation.

### Summary

This chapter has been an eye-opener, huh? We covered a lot of ground. A lot of weird stuff, too. Makes you wonder about intelligence, doesn’t it? Anyway, you should have a good grasp of AI now. Both ad hoc and robust techniques have been covered. We talked about deterministic algorithms, decision trees, planning, scripting languages, neural networks, genetic algorithms, and fuzzy logic. And I would venture to say that you could give any professional game programmer a run for his/her money on the subject of AI, if not blow them away!

Previous | Table of Contents | Next

Copyright © Macmillan Computer Publishing, Inc.

Products | Contact Us | About Us | Privacy | Ad Info | Home
Use of this site is subject to certain Terms & Conditions, Copyright © 1996-2000 EarthWeb Inc. All rights reserved. Reproduction in whole or in part in any form or medium without express written permission of EarthWeb is prohibited. Read EarthWeb's privacy statement.