Boost logo

Boost :

Subject: [boost] [MSM] Single event, multiple orthogonal submachines
From: Andrew Hundt (athundt_at_[hidden])
Date: 2012-05-23 15:40:30


I'm trying to deal with having multiple orthogonal submachines that
process one event containing data. I have a contrived example that
hopefully conveys the issue. Suppose I am hoping to create a state
machine "Game2D" with a set of orthogonal submachines that guard
certain transitions based on each other, and I would like some events
to be processed by multiple submachines.

Parent Machine:
Game2D

Event:
CharacterStatus - contains character position and velocity

Submachines:
IsMoving - changes state based on CharacterStatus
CorrectPosition - updates position based on CharacterStatus
CharacterStatusUpToDate - times out to an error state if
CharacterStatus hasn't been received for a while
EnemyAlive - doesn't process CharacterStatus
RunSystem - guards some transitions based on the state of IsMoving

Since some, but not all of these submachines needs the
"CharacterStatus" event, what is the best way to make sure they all
get it when I call Game2D.process_event(CharacterStatus)?

I want to be able to reuse these pieces, and keep things as simple as
possible. Does this seem like an ok approach? Should I simply have a
state "UpdateCharacterStatus" that directly updates each of these
objects then creates an event to transition away, or something else
entirely?

Cheers!
Andrew Hundt


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk