Game Development Reference
Rule-based systems lend themselves to a somewhat Darwinian approach to
coding the AI. Game AI programmers add their best rules to the system and test
it. Rules that never fire are considered suspect. They address inadequacies in the
AI by adding new rules or improving existing ones. Then they balance the rules in
the framework with careful tuning.
How many rules are required? This will depend on the game and the desired
quality. To play Sudoku , two rules will solve any board that has a difficulty level
below ''evil.'' To play Minesweeper , three rules suffice to play every move of a
beginner- or intermediate-level board and nearly every move of an expert-level
board [Kirby08]. Yet at one point in time, the SOAR Quakebot had more than
300 rules [Laird].
How complicated will the framework need to be? Simpler games do not allow
concurrent rule execution; the AI is expected to pick a single move or do one
thing during its turn. Concurrent rule execution is too complex for most
beginning game AI programmers doing their first rule-based AI. But without
concurrent rule execution, the framework still needs a method to select a rule
when more than one rule matches. The rules need a method to report how well
they match, and the framework needs a method to select among them. This can
be as simple as comparing integers using a fixed algorithm, or it can be very
complex. A glance back at the section ''Multiple-Transition Review'' in Chapter 3
might be in order. Do not make your methods complex until tuning demands it.
There are many advantages to rule-based game AI. The rule structure helps
contain complexity without the straightjacket of a state-based approach. When
the rules are based on human play, the AI plays like a human. When the rules
loaded into a rule-based system come from a high degree of expertise, the system
usually exhibits that same level of expertise. Simple rule-based systems are within
the reach of a beginning AI programmer. The execution part of a rule can be as
complex as required to do the job. There are no constraints to get in the way.
Rule-based systems also have disadvantages. It is very hard to have a good rule for
every situation. The method places strong demands on some general rules to
cover default behaviors. Writing rules takes human expertise at the task at hand.
This is true of most beginning AI techniques. There is no inherent structure to