A study of "Programming Game AI by Example, chapter 2, State Machines".