[Tutor] what's a state machine?
Alan Gauld
alan.gauld at blueyonder.co.uk
Thu Aug 7 01:16:56 EDT 2003
> > You then define numeric values(or hash keys) for each state
> > and each event, load pointers/rferences to functions into
> > the action column
>
> Does that work when you have multiple concurrent states, like
> simultaneouly Walking and ChewingGum at the same time?
There are two approaches to this problem.
1) Combining states, eg of walking-with-gum
So you then get:
chewing-gum-still
walking-without-gum
walking-with-gum
etc
This can quickly escalate to an unmanageable "state explosion"
so ...
2) Use "nested states", which implies a second state machine(table)
inside the first. This works OK up to about 3 levels then it gets
messy. But then again if you really have that amount of nested
state its going to be messy no matter how you build it!
Nested states is the approach advocated in UML, using Harel charts
to represent the nested states.
Most real world situations are covered by two state levels plus
a combined state model for the inner cases. A combination of
(1) and (2)...
Alan G.
More information about the Tutor
mailing list