Chapter 11. Rule-Based Systems
Rule-based systems (RBSs) essentially consist in a collection of "if...then" statements. Such statements are particularly suited to encoding rules-of-thumb, similar to human expertise. Experts generally apply such knowledge mechanically to a problem to solve it. By transferring their experience into the computer, the same process can be done with similar reliability, but in a much more efficient and automated fashion.
In games, RBSs can be used in nonplayer characters (NPCs) for two distinct purposes: problem solving (reaching a single conclusion from initial facts) or control (producing a sequence of actions in a simulation). In problem solving, the rules explain the connection between different truths (for instance, "If an item is absent, then someone picked it up") so the system can reach the answer. As for control, the rules describe the action that should be taken in each situation (for instance, "If there's a wall ahead, then stop").
In practice, RBSs have the advantage of separating behaviors from the code. Of all the techniques that allow this data-driven approach, RBSs are the simplest to develop, extremely fast at runtime, very flexible, and easily extended.
This chapter covers the following topics:
The next chapter covers the implementation and application of RBSs, but this chapter will provide a solid background to build upon.