Finite State Machines
Richard "Superpig" Fine - saving pigs from untimely fates - Microsoft DirectX MVP 2006/2007/2008/2009
"Shaders are not meant to do everything. Of course you can try to use it for everything, but it's like playing football using cabbage." - MickeyMouse
The rule I refer to is this:
In a Finite State Machine, the only form of connection between components is a three-point connection: from an event, to a state, to a state.
Can anyone think of any exception at all to this, or possibly prove me right?
Richard "Superpig" Fine - saving pigs from untimely fates - Microsoft DirectX MVP 2006/2007/2008/2009
"Shaders are not meant to do everything. Of course you can try to use it for everything, but it's like playing football using cabbage." - MickeyMouse
------------------------------
There are only 10 kinds of people: those that understand binary and those that don't.
For example, take the ghosts in Pacman. They have three states - Hunter, Hunted, and Eaten. Say the ghost is in the Hunter state. Pacman eats a powerpill, so all ghosts move into the Hunted state. Normally, a timer event would occur after a given amount of time (to set the states back to Hunter), but if Pacman eats another powerpill before that happens, then the ghosts ''re-enter'' Hunted state. This has the effect of resetting the timer.
Superpig
- saving pigs from untimely fates
- sleeps in a ham-mock at www.thebinaryrefinery.cjb.net
Richard "Superpig" Fine - saving pigs from untimely fates - Microsoft DirectX MVP 2006/2007/2008/2009
"Shaders are not meant to do everything. Of course you can try to use it for everything, but it's like playing football using cabbage." - MickeyMouse
Timer==0 is an event that triggers a transition from state "hunted" to "hunter":
[hunted]----(timer==0)---->[hunter]
So you''d not re-enter the state, just reset the timer so that the triggering event occurs a little later....
------------------------------
"Reality is nothing, perception is everything!" - First Wizard Zeddicus Zu''l Zorander
------------------------------
There are only 10 kinds of people: those that understand binary and those that don't.
Another way of doing it would be to store the clocktime when the state was entered, and then keep checking that time against the current clocktime (i.e. when the currentTime>=startTime+10) or something like that.
But implementation isn''t the point. The ''state timer expires'' event is purely symbolic, the actual way it''s done is irrelevant.
Well, ok, so maybe the ''re-entrant'' states aren''t strictly necessary. But they''re not the issue here!
Can anyone (*without* further pedantry, please ) think of any examples of an FSM which does not follow the trigger-startstate-endstate pattern?
Superpig
- saving pigs from untimely fates
- sleeps in a ham-mock at www.thebinaryrefinery.cjb.net
Richard "Superpig" Fine - saving pigs from untimely fates - Microsoft DirectX MVP 2006/2007/2008/2009
"Shaders are not meant to do everything. Of course you can try to use it for everything, but it's like playing football using cabbage." - MickeyMouse
quote: Original post by superpig
Can anyone (*without* further pedantry, please ) think of any examples of an FSM which does not follow the trigger-startstate-endstate pattern?
No. There is none.
As an aside, have you considered basing your application off an existing diagramming solution (eg Dia, Kivio)? Kivio is only available for KDE, but Dia is available for all Unices and Win32. They''re both under the GPL. Given all of Kivio''s features, you might even want to consider porting/forking it to whatever platform you''re working with.
Dia homepage
Dia Win32 Installer
Kivio project page (just in case you''re interested)
Plus I need practice at MFC.
I intend to build in a ''simulator'' part of the program - where you can set up a number of ''instances'' of the machine, and then fire off events to check that everything happens the way you expect it to. Kivio can''t do that.
And as for there being none: I think you''re right, by the nature of the machine, but is there a proof somewhere, please? I''ve already coded it on the assumption that there is no exception, but if I have to change that I''d rather change it now than later...
Superpig
- saving pigs from untimely fates
- sleeps in a ham-mock at www.thebinaryrefinery.cjb.net
Richard "Superpig" Fine - saving pigs from untimely fates - Microsoft DirectX MVP 2006/2007/2008/2009
"Shaders are not meant to do everything. Of course you can try to use it for everything, but it's like playing football using cabbage." - MickeyMouse
You could invert the model, but it would be the same model.. as in: begins in an "end state" (a search routine), encounters an event (a data object), and finishes in a "start state" (an acquisition routine). the default being "on" instead of "off".