Analytical Perspectives in Game Design


 

All Packages  Class Hierarchy  This Package  Previous  Next  Index

Class bvyy.smf.GeneralStateModel

java.lang.Object
   |
   +----bvyy.smf.StateMachine
           |
           +----bvyy.smf.GeneralStateModel

public class GeneralStateModel
extends StateMachine
Make a general purpose state model.

Intent

This is a generic state machine where the definition will be provided from an external source such as data file.

There is an assumption in here that the state machine will have fewer than the theoretically possible transitions. If it has more than say 80% the I really need to write a highly meshed transition class.

Motivation

Allow the game desingers to specify state machines that I could not have envisionaged. Maked the game customisable by a non-computer literate author with no need to write code.

Version:
0.0.3 24 May 1998
Author:
(c) 1998 Brian Voon Yee Yap

Constructor Index

 o GeneralStateModel()
Implements a one state state-machine default constructor.

Method Index

 o addStateChange(String, String, String)
 o fireStateChange(ModifiableChangeEvent)
Change the state from the current state to a new state.
 o GeneralStateModel(StringTokenizer)
Produces a state machine according to the follwing specification:
 o getState()
Returns the current state of the state machine.
 o getStateTransitions()
Gets the states that can be reached from the current state.
 o removeStateChange(String, String)

Constructors

 o GeneralStateModel
 public GeneralStateModel()
Implements a one state state-machine default constructor.

Methods

 o GeneralStateModel
 public void GeneralStateModel(StringTokenizer specification)
Produces a state machine according to the follwing specification:

Parameters:
spec - The format of the input token shall be:
  • GSM,[major version],[minor version]
  • name
  • defaultState
  • NumberofStates
  • StateName
  • NumberOfTransitions
  • State1=State2=verb
where:
  • the delimeter is "|"
 o fireStateChange
 public void fireStateChange(ModifiableChangeEvent newState) throws PropertyVetoException
Change the state from the current state to a new state. If the state request is not possible then no transition happens. This might happen in a multi-user game where another user has acted just before this user.

Parameters:
newState - is a property change event, caller, "state", string, string.
Throws: PropertyVetoException
thrown if a vetoable listener vetoes the change.
Overrides:
fireStateChange in class StateMachine
 o getState
 public String getState()
Returns the current state of the state machine.

Overrides:
getState in class StateMachine
 o getStateTransitions
 public String getStateTransitions()
Gets the states that can be reached from the current state. An array of new states is returned. the format of the response is:
  • GSM,[major version],[minor version]
  • name
  • defaultState
  • NumberofStates
  • StateName
  • NumberOfTransitions
  • State1=State2=verb
where:
  • the delimeter is "|",
  • defaultState = current state,
  • number of states = 1, and
  • the state is the current state.

Overrides:
getStateTransitions in class StateMachine
 o addStateChange
 public void addStateChange(String fromState,
                            String toState,
                            String verb)
 o removeStateChange
 public void removeStateChange(String fromState,
                               String toState)

All Packages  Class Hierarchy  This Package  Previous  Next  Index

22/11/99

 


See also: [Role Playing Games] [Game Engine]
© 1998, 1999 Brian Yap. These pages are available under the GNU licence.