Analytical Perspectives in Game Design


 

All Packages  Class Hierarchy  This Package  Previous  Next  Index

Class bvyy.smf.DiscreteLinearStateModel

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

public class DiscreteLinearStateModel
extends StateMachine

Make a state machine in the manner of a linked list. This is a flyweight pattern.

Intent

To implement a state machine for linear models. (For exampe a numeric list, where you can move along the list by n items.)

Motivation

To reduce the number of classes required for this specific type of state machine and hence improve performance. State is recorded as an interger rather than a series of state classes.

Version:
1.0.2 24 May 1998
Author:
(c) 1998 Brian Voon Yee Yap
See Also:
ContinuousLinearStateModel

Constructor Index

 o DiscreteLinearStateModel()
 o DiscreteLinearStateModel(String)
Construct a state machine.

Method Index

 o fireStateChange(ModifiableChangeEvent)
Change the state from the current state to a new state.
 o getDefaultValue()
Get the default value.
 o getDownVerb()
Gets the down verb.
 o getMax()
Get maximum value
 o getMin()
Get minimum value
 o getState()
Returns the current state of the state machine in a StringTokenizer.
 o getStateTransitions()
Gets the states that can be reached from the current state.
 o getUpVerb()
Gets the up verb.
 o setDefaultValue(int)
Set the default value.
 o setDownVerb(String)
Sets the down verb.
 o setMax(int)
Set maximum value.
 o setMin(int)
Set minimum value.

If the current value, or default values are less than the new minimum they will be set to the new minimum.

 o setUpVerb(String)
Sets the up verb.

Constructors

 o DiscreteLinearStateModel
 public DiscreteLinearStateModel()
 o DiscreteLinearStateModel
 public DiscreteLinearStateModel(String spec)
Construct a state machine.

This method is synchronised to prevent conflicts from other clients who might want to update the state of this machine. They will have to wait until after the object is created.

Parameters:
spec - The format of the input token shall be:
  • LSM,[major version],[minor version]
  • name
  • defaultvalue
  • maxValue
  • minvalue
  • upVerb
  • downVerb
The delimeter is |.

Methods

 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.

Modifiers are not implemented in this version.

Parameters:
newState - is a property change event. The old and new value objects should be string objects.
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 in a StringTokenizer.

The format of the StringTokenizer is:

  • myName,[major version],[minor version]
  • myvalue

Overrides:
getState in class StateMachine
 o getStateTransitions
 public String getStateTransitions()
Gets the states that can be reached from the current state. A StringTokenizer of new states is returned.

The format of the StringTokenizer is:

  • LSM,[major version],[minor version]
  • name
  • currentvalue
  • maxValue
  • minvalue
  • upVerb
  • downVerb
The delimeter is "|".

Overrides:
getStateTransitions in class StateMachine
 o setDefaultValue
 public void setDefaultValue(int newDefault)
Set the default value.

Parameters:
newDefault - The default is set to this value unless it is outside the maximum or minimum value. The it is set to the maximum or minimum value.
 o getDefaultValue
 public int getDefaultValue()
Get the default value.

 o setMax
 public void setMax(int newMax)
Set maximum value.

If the current value, or default values are greater than the new maximum they will be set to the new maximum. This in turn will fire any necessary validations. If this change is voided, then nothing is done.

If the maxvalue is below the minimum value then the maximum value will be set to the minimum value.

Parameters:
newMax - The new maximum value.
 o getMax
 public int getMax()
Get maximum value

 o setMin
 public void setMin(int newMin)
Set minimum value.

If the current value, or default values are less than the new minimum they will be set to the new minimum. This in turn will fire any necessary validations. If this change is voided, then nothing is done.

If you attempt to set the minimum above the maximum, it will be set to the maximum.

Parameters:
newMin - The new minimum value.
 o getMin
 public int getMin()
Get minimum value

 o setUpVerb
 public void setUpVerb(String newUpVerb)
Sets the up verb.

Parameters:
newUpVerb - the new verb.
 o getUpVerb
 public String getUpVerb()
Gets the up verb.

 o setDownVerb
 public void setDownVerb(String newDownVerb)
Sets the down verb.

Parameters:
newDownVerb - the new verb.
 o getDownVerb
 public String getDownVerb()
Gets the down verb.


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.