Class FSM
- Known Subclasses:
-
Agent
A simple FSM (Finite State Machine), a base class for most objects in
the game.
An FSM is characterized by states and state update functions (actions)
defined for its states. Not all states have actions associated with them.
Actions are stored in a dictionary and can be retrieved by state id
(name).
When FSM's update() function is called, it calls self.action(), where
self.action is a pointer to the current action. Set State function of FSM
updates this pointer depending on the current state.
The basic FSM doesn't have any message handling.
| Method Summary |
| |
__init__(self,
name)
|
| |
setAction(self)
Looks for the action by key=self.currState, sets it if found. |
| |
setState(self,
state)
Sets the current action function in addition to just changing the
state variable. |
| |
trace(self,
arg)
A simplistic debug function |
| |
update(self,
timeInc)
Updates the state and returns it as the result. |
| |
updateAction(self,
timeInc)
Calls current action function if it is set. |
setAction(self)
Looks for the action by key=self.currState, sets it if found.
-
|
setState(self,
state)
Sets the current action function in addition to just changing the
state variable. Returns 1 if the state was changed, 0 otherwise.
-
|
trace(self,
arg)
A simplistic debug function
-
|
update(self,
timeInc=1)
Updates the state and returns it as the result.
-
|
updateAction(self,
timeInc=1)
Calls current action function if it is set.
-
|