a Finite and Hierarchical State Machine (FSM / HSM) to design simulators and games in JQuery