Game Development Reference
In-Depth Information
Txn.Initialize (GetType(HidingState).Name)
'Add it to our list of transitions
'Then react to health - if high, attack
Txn = New HighHealthTxn()
'Set the next state name of that transition
'Add it to our list of transitions
End Sub
This is very similar to the New() code for AttackState . The first transition is
identical; it has the same criteria and the same next state. The second transition
uses a different transition, and it goes to a different state, so of course the
comment is changed as well. The final step remaining is to get these states into the
Switch to the Code view of Monsters.vb and go to the Load event handler. Below
the existing call that loads the Hiding state, add these lines:
Brains.LoadState(New AttackState)
Brains.LoadState(New FleeState)
Recall that the first state loaded is the Start state, so make sure these lines come
after the line that loads the Hiding state. Now select Start Debugging from the
Debug menu. Change the settings on the user interface and click Think to watch
the monster react. This monster AI is pretty simple, but with a few more states it
would be as smart as the monsters in the original version of Doom .
Chapter Summary
This chapter shows that a collection of a few simple states and transitions is
enough for many simple game AI tasks. Once the framework is created and
understood, new behavior states can be added quickly and easily without
every new capability added. Using this technique, game AI programmers can
quickly turn a design diagram into changing behaviors in a game. While
experienced programmers often use FSM, they also know when not to use
them and how to modify them to control complexity and ensure intelligent
Search Nedrilad ::

Custom Search