Game Development Reference
Our state objects need four methods for normal operation:
n An entry method. The entry method will be called once by the machine
when it transitions into a new state.
n An update method. The update method will be called when the machine
elects to stay in the current state.
n An exit method. The exit method will be called to clean up when the
machine leaves the current state.
n A transition-check method. This method determines if the machine should
transition out of the current state. Our states will check their transitions
in the order they were loaded and use the first valid transition. This will
provide a mechanism for dealing with ambiguous transitions.
Our state objects will also need to initialize themselves. When the state is created,
it will load a list of transitions out of the state. In our implementation, transitions
are stored in the state that the transition comes from.
Our transitions will be very simple. They have a method that indicates if they are
valid when checked against the current world conditions. That method indicates
the state to which the machine should transition.
The Machine Object
The Machine object will present a RunAI method to the world. This is how the
world asks the AI to do some thinking. In addition, it needs a way to load the
states and transitions. We will do this by loading the Machine object with states.
The first state loaded into the Machine object will be the Start state.
The Monster Object
The Monster object will actually be a Windows form, which is also a type of
object. It will provide the user interface. The user will be able to adjust whether
the monster sees players or not as well as adjust the monster's health between low
and high. The Monster object will make both of those adjustments available to
the AI. The Monster object will also have an output window to show what it is