creating a state machine to controle the game

- allowing to restart game a few seconds after game lost
- major refactoring on node structures