|
|||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||
java.lang.Objectorg.generation5.ai.FSM
Implements a finite-state machine. This class implements the Visualizable
interface to display the FSM in a graphics context.
| Nested Class Summary | |
static class |
FSM.State
The FSM states. |
| Field Summary | |
protected FSM.State |
currentState
The current state in the FSM is in. |
protected FSM.State[] |
fsmStates
An array of the states in the finite-state machine. |
protected int |
numStates
The number of states in the FSM. |
protected int |
renderSize
The size of the states to be rendered. |
| Constructor Summary | |
FSM()
Creates a new instance of FSM |
|
FSM(FSM.State initialState)
Creates a new instance of FSM with an initial state. |
|
FSM(int maxStates)
Creates a new instance of FSM, with the maximum number of allowed states. |
|
FSM(int maxStates,
FSM.State initialState)
Creates a new instance of FSM with an initial state and the maximum allowed states. |
|
| Method Summary | |
int |
addState(FSM.State state)
Add a state to the FSM. |
int |
addStates(FSM.State[] states)
Adds an array of states to the FSM. |
void |
addTransition(FSM.State start,
int transition,
FSM.State end)
Add a transition to the finite state machine. |
FSM.State |
getCurrentState()
Return the current state the FSM is in. |
int |
getRenderSize()
Return the current render size. |
FSM.State |
getState(int i)
Retrieve the given state from the FSM. |
int |
getStates()
Return the number of states in the FSM. |
static void |
main(java.lang.String[] args)
A simple test function. |
void |
removeAllStates()
Remove all states. |
void |
render(java.awt.Graphics g,
int width,
int height)
Render the FSM in a graphics context. |
void |
setRenderSize(int rs)
Set the size (in pixels) to render the states. |
void |
setState(FSM.State state)
Set the current state of the finite-state machine. |
FSM.State |
transition(int transition)
Transition the FSM from one state to another with a given transition identifier. |
void |
writeImage(java.lang.String s,
int width,
int height)
Write the FSM to an image. |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
protected int numStates
protected FSM.State currentState
protected FSM.State[] fsmStates
protected int renderSize
| Constructor Detail |
public FSM()
public FSM(int maxStates)
maxStates - the maximum number of states allowed in the FSM.public FSM(FSM.State initialState)
initialState - the initial state.
public FSM(int maxStates,
FSM.State initialState)
maxStates - the maximum number of states.initialState - the initial state.| Method Detail |
public FSM.State getCurrentState()
public int getStates()
public void setState(FSM.State state)
state - the state.public int addState(FSM.State state)
state - the state to be added to the FSM.
public int addStates(FSM.State[] states)
states - the array of States to add to the FSM.
public void removeAllStates()
public void addTransition(FSM.State start,
int transition,
FSM.State end)
fsm.addTransition(state1, transition, state2);
// ...is equivalent to:
state1.addTransition(transition, state2);
start - the start state.transition - the transition identifier.end - the end state.public FSM.State transition(int transition)
NullPointerException if the transition
isn't defined for the current state.
transition - the transition identifier.
public FSM.State getState(int i)
i - the index of the state to return.
public static void main(java.lang.String[] args)
args - the command line argumentspublic void setRenderSize(int rs)
rs - the new render size.public int getRenderSize()
public void render(java.awt.Graphics g,
int width,
int height)
render in interface Visualizableg - the graphics context.width - the width of the context.height - the height of the context.
public void writeImage(java.lang.String s,
int width,
int height)
writeImage in interface Visualizables - the filename of the image.width - the width of the image.height - the height of the image.
|
This documentation is part of the Generation5 JDK.
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||