Fuzzy Rules

Given the variables just defined, we're ready to create the behaviors as a set of rules. To achieve this, we'll use the case studies from Chapter 29, "Analysis and Specification."

Using Doors

The set of rules required to move through a door is that we need to press the button first, and then move through the door when it's ready. The rules, displayed in Table 31.1, reflect the simplicity of the task, involving only four fuzzy terms.

Table 31.1. The Fuzzy Rules That Control the Animat While It Opens and Moves Through an Arbitrary Door

Condition

Action

If not button_pressed

Turn to button, move forward

If button_pressed

Turn to door

If button_pressed and door not fully open

Move stop

If door fully open

Move forward, turn to door

It's important to note that this set of fuzzy rules relies on being interrupted once the door is crossed. The higher-level AI identifies this is the case, and stops calling this fuzzy behavior. The problem is that the animat will continue to try to get through the door again (backwards) once the door has been used. Preventing this problem would require another few symbols and additional rules, thereby complicating the system. It's is certainly feasible and even desirable to only let these rules handle the door scenario, and nothing else.

In brief, the behavior does need to specify to stop turning toward the button; in rule 1, the membership value of the action will drop toward 0 when the button is pressed. The same applies for the movement.

Using Ladders

Ladders are equally simple to deal with by using fuzzy rules. The hardest work has been done by the time the rules are written. To climb a ladder, the animat must first move toward it and grab hold of it (handled automatically). Then, it must look up and press forward until the top of the ladder is reached, at which point the animat can look ahead to dismount. Table 31.2 lists the fuzzy rules that express this.

Table 31.2. Set of Fuzzy Rules That Guide an Animat Toward a Ladder, Up the Rungs, and Dismount at the Top

Condition

Action

True

Move forward

If ladder is not held

Turn to ladder

If ladder is held

Look up

If ladder is top

Look ahead, turn to exit

Once again, we'll assume that these fuzzy rules are no longer called by the higher-level AI after the animat has dismounted from the ladder. These fuzzy rules are only expected to be applied to their intended domain.

Using Platforms

The use of platforms involves more actions in the sequence than the previous two behaviors. Consequently, the rulebase is slightly more complex, but the principles remain the same. The animat presses the button and gets onto the platform (see Table 31.3).

Table 31.3. A Longer Sequence of Rules Needed for the Animat to Climb onto Platforms, Wait, and Disembark

Condition

Action

If not button_pressed

Turn to button, move forward

If button_pressed and platform not ready

Move stop

If button_pressed and not aboard

Turn to platform

If platform is ready

Move forward

If aboard

Turn to exit

If aboard and platform has not arrived

Move stop

If aboard and platform has arrived

Move forward

Again, we assume the behavior is disengaged after the platform has been dismounted. By making the rules as specific as possible, we can also avoid having to specify behaviors such as "stop looking toward the platform."



AI Game Development. Synthetic Creatures with Learning and Reactive Behaviors
AI Game Development: Synthetic Creatures with Learning and Reactive Behaviors
ISBN: 1592730043
EAN: 2147483647
Year: 2003
Pages: 399

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net