Analytical Perspectives in Game Design
State Machines
Home ] Up ] utility classes ] GUI object model ] [ State Machines ]


 

A characteristic is uses to describe the attributes and behaviour of other objects in the game. (At the moment only Things.)

State Machine Data File Format

There is a very specific data file format that you must follow when writing game machines. All state machines have the following header

{Object = State-Machine}                                                 

All state machines must have the following parts.

variable spacer value optional default value comment
name = string No N.A.
type = [linear | general] No N.A.

The following items only apply to linear state machines:

variable spacer value optional default value comment
min = integer Yes 0
max = integer No N.A.
upVerb = string No N.A.
downVerb = string No N.A.
default = integer Yes 0 This is the starting value. Also if the state machine is reset it will be sent back to this value.

The following items only apply to general state machines:

variable spacer value optional default value comment
state = string No N.A.
stateTransition = state1, state2, verb No N.A. describes that this transition is allowed and the desciprion of the transition.
default = state No N.A.

The following items are optional and can be supplied to all state machines.

variable spacer value optional default value comment
modifies = GameName Yes ParentThing
stateCommandBlock = state, command, action Yes state, command, noBlock this is used to specify the decorative action to be performed.

Characteristics are implemented with the following object model.

A characteristic can represent many things that tell us something about the current state of the machine. It could be a text label (name, alias, mood), a state machine, a picture in 2D, a 3D representation.

An audio characteristic provides a audio based description of the object for playing through the game window.

A 2D and (later) a 3D characteristic can provide information on the display and manipulation of an object.

A string characteristic provides a textual set of descriptions for the object.

A state machine has a definition file.This allows the creation of any number of state machines to customise the world.

As part of the command processing the state machine can return token, containing the valid states that can be achieved from this state and the plain English command that represents the state transition.

States can be used to manage many things: For example:

  • game state = setup, running, closedown, stopped
  • health = 1,2,3,4,5,6,...,N
  • door = open, closed
  • lockable door = locked open, unlocked open, locked shut, unlocked shut

I have deliberately not made state machines containers. So a door state machine must explicitly be lockable or the door game thing must contain a lock.

Part Description Example
name The name of the state machine. This is used in the description of the machine on the screen.

Name = text

Door State
State The state machine has a list of allowable states.

State = text

State
Closed
Open
Transitions The state transitions have a set of words used to describe the transitions.

from state = to state = action verb.

If no transition is given between 2 states, then the state is not allowed.

The state machine will use a combination of the text to describe the state transition. So we can have "slide" + "open".

From ID To ID Text
Closed Open Slide
Open Closed Slide

To create a door with a separate lock that effects the operation of the door, the lock needs to be told that it is part of the door opening mechanism.

Part Description Example
modifies The name of the game thing instance that is to be modified and the state machine that is effected. Door|Door State
 

22/11/99

 


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