Game Development Reference
In-Depth Information
parallel—or at least all of them that do not place conflicting demands on
classroom resources.
Rule-based systems consist of a collection of rules and the framework to apply
them. When the AI is asked to think, the current state of the world is presented to
the rules. Each rule determines if it matches the current situation. From among
the matching rules, the framework activates one or more of them.
Besides being familiar from classroom experience, you may recognize that the
transition checking done by the states in the FSM project of Chapter 3, ''Finite
State Machines (FSMs),'' fits the definition of a rule-based system. The transi-
tions out of a state are checked for a match; the system picks one of the matching
transitions and changes the FSM state. Just as in an FSM, where multiple tran-
sitions may be valid, there may be multiple rules that match in a rule-based
system. Unlike an FSM, however, a rule-based system need not be limited to
activating only a single rule. Activating multiple rules forces the programmer to
deal with the issues of conflict and efficiency. The activated rules must not
conflict with each other; ''go left'' and ''go right'' may both be valid responses,
but one precludes the other. Evaluating all the rules ensures that the best response
can be used, but it has a direct impact on efficiency. Conflict resolution and
efficiency concerns suggest that the rules be prioritized in some way, the simplest
method being that the first rule to match is the only rule to be activated.
Let us examine what rules are. Done properly, rules are a collection of really good
ideas about what to do, combined with the knowledge about when to use them.
This means that there are two parts to each rule: the matching part and the
execution part. For game AI, intelligence comes from sufficient rules with good
execution, and stupidity comes from bad matching or too few rules.
Rules have to determine whether they match the current situation. Recall our
simulated opera singer who confused a funeral gathering with a small theater and
broke into song. His problem is not in the execution part; we made no comment
on his singing skills, and no one at the funeral really cared. His problem is in the
matching part. The AI could be missing a rule specifically for funerals; the near
match of the funeral situation with a theater situation meant that it was the best-
matching rule in the AI, so it was the rule used. Alternatively, if the AI had a rule
for funerals, and somehow the rule for theater was selected instead, then the
matching part of the funeral rule might be miscoded or poorly prioritized. That
is, the framework might not have disambiguated the matched rules properly, or
the design of the matching system might not be adequate.
 
Search Nedrilad ::




Custom Search