Complex “finite state machines” – easily implemented:

Originally shared by Guido Stepken

Complex “finite state machines” – easily implemented:

A short tutorial: http://www.gedan.net/2008/09/08/finite-state-machine-matrix-style-c-implementation/

And one with function pointers: http://stackoverflow.com/questions/1371460/state-machines-tutorials

Both are working with decision tables, which are very easy to verify. You can even print them out, edit them in EXCEL, … No longer “if then else if if …” – orgies, no complex parsers, … just plain “C”.

And i can tell you – blindingly faaaaaaast!!!

Very well suited for implementing “Business Administration Rules” ( Business Process Management, , ) or for defining “behaviour” of RPi GPIO, traffic lights, robots, ….

Have fun!ļ»æ