https://news.ycombinator.com/item?id=16468280
http://habrahabr.ru/post/241941/
https://news.ycombinator.com/item?id=14634947
Decision Tables
http://stackoverflow.com/questions/116907/how-to-use-decision-tables-to-help-your-application
http://bcastuff.blogspot.com/2013/02/decision-table.html
http://sourceforge.net/projects/logician/
http://digirulesolutions.com/drupal/tutorial
http://en.wikipedia.org/wiki/Finite_State_Machine
http://www.complang.org/ragel/
http://www.embeddedrelated.com/showarticle/543.php
http://www.devexp.ru/2011/02/konechnye-avtomaty-v-c/
http://www.codeproject.com/Articles/406116/Generic-Finite-State-Machine-FSM
http://stackoverflow.com/questions/4275602/boost-statechart-vs-meta-state-machine
http://www.state-machine.com/psicc/
http://habrahabr.ru/post/160105/
http://www.rsdn.ru/summary/671.xml
http://www.rsdn.ru/article/alg/Static_Finite_State_Machine.xml
http://gameprogrammingpatterns.com/state.html
http://www.drdobbs.com/cpp/state-machine-design-in-c/184401236
Python
https://github.com/jtushman/state_machine
https://github.com/tyarkoni/transitions
http://tech.pro/tutorial/1516/representing-state-machines-with-co-routines-in-python
Java
FSTs have key applications in speech recognition and synthesis, machine translation, optical character recognition, pattern matching, string processing, machine learning, information extraction and retrieval among others. Often a weighted transducer is used to represent a probabilistic model:
http://www.openfst.org/twiki/bin/view/FST/WebHome
Better representation of states using bit flags and masks. For example you can have states like:
IDLE = 1<<0 RUNNING = 1<<1 JUMPING = 1<<2 CROUCHING = 1<<3 SHOOTING = 1<<4 ...
Then use bit masks for valid operations/actions:
CAN_JUMP = ~(JUMPING|SHOOTING|CROUCHING) CAN_SHOOT = ~(SHOOTING|JUMPING) CAN_RUN = ~(RUNNING|CROUCHING) ...
Then in your input code instead of having a bunch of nested ifs, it can be simplified to:
case INPUT_JUMP: if (player_state & CAN_JUMP) { do_jump(); } case INPUT_SHOOT: if (player_state & CAN_SHOOT) { do_shoot(); } ...
Setting the player into a certain state
void do_shoot() { player_state |= SHOOTING; ... } void stop_shooting() { player_state &= ~SHOOTING ... } void do_jump() { player_state |= JUMPING ... } void hit_ground { player_state &= ~JUMPING } ...
With flags, you aren't forced in a particular state which can lead to other bugs when having nested states though inheritance. It also makes your code much more easy to follow and extend with new actions and states without worrying about breaking other states.