Wednesday, January 25, 2006

Game Programming Wisdom

Here are some hints for game programming:

  • You have lots of alternatives to implement AI to your game. Some of them complex and academic and some of them practical. If you are programming a game than you should not use neural networks or genetic algorithms. Not only their programming but also test and debug is very hard.
  • Faced with tight schedules and minimal resources, the game AI community has eagerly ambraced rules-based systems as the easisest type of AI to create, understand and debug.
  • Winning, losing and losing well: An AI that wins( or loses) most of the time is fairly easy to develop. Most games can vary the number and quality of opponents to affect the desired end. In an RTS, for example, army size and rock-paper-scissors adjustments can mean the difference between victory and defeat. In an FPS or sports simulation, accuracy and speed of opponents can be adjusted. The real issue in these cases in the believability of the opponent. Huge armies early in the game in an RTS are not possible without obvious cheating. Massive waves of enemies in an FPS tend to point to a lack of attention to AI.
  • Making characters intelligent is a real problem. Instead of trying to make them intelligent, Will Wright, in The Sims, solved the real problem (intelligent behavior) by turning the second one ( identifying and locating) around. What he called "smart terrain" made it far easier for the Sims to get what they needed. Smart terrain is the idea that objects on the terrain broadcast what they offer to any Sims that might be passing by. The Sims do not identify these objects on the terrain; they instead listen to what the terrain is telling them. The attractiveness of the objects that meet the current needs of a Sim cause the Sim to move toward them. For example, a refrigerator might broadcast the fact that it can satisfy the "hunger" need. If a Sim is getting hungry and walks within the influence of the refrigerator, the Sims might decide to fulfill his hunger need with that object.
  • Game AI programmers should live by the K.I.S.S plan, and Keep It Simple Stupid! AI systems should allow designers and programmers to do the complex things with simple parts; parts that are easy to comprehend, reuse, debug, and mantain. Simple parts have a better chance of surviving the inevitable code changes required as the game design evolves.
  • Every AI system should check for success conditions within a reasonable amount of time. If these conditions are not met, the AI should give up and try something else. At a minimum, an agent can fall back to interesting idle animations that express the agent's confusion or frustration. If enough processing power is available, the agent can reevaluate its situation and formulate a new plan.
  • Create variety through the data, not through the code.

references: AI Game Programming Wisdom

No comments: