How to implement a FSM – Finite State Machine in Java

The heart of a state machine is the transition table, which takes a state and a symbol (what you’re calling an event) to a new state. That’s just a two-index array of states. For sanity and type safety, declare the states and symbols as enumerations. I always add a “length” member in some way (language-specific) … Read more

Python state-machine design

I don’t really get the question. The State Design pattern is pretty clear. See the Design Patterns book. class SuperState( object ): def someStatefulMethod( self ): raise NotImplementedError() def transitionRule( self, input ): raise NotImplementedError() class SomeState( SuperState ): def someStatefulMethod( self ): actually do something() def transitionRule( self, input ): return NextState() That’s pretty … Read more