> For the complete documentation index, see [llms.txt](https://asrob-uc3m.gitbook.io/robotdevastation-developer-manual/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://asrob-uc3m.gitbook.io/robotdevastation-developer-manual/robotdevastation/game-fsm.md).

# Game FSM

The Game FSM, implemented in [GameStateLib](https://asrob.uc3m.es/robotDevastation/group__GameStatesLib.html) using the [State Machine Library](/robotdevastation-developer-manual/robotdevastation/game-fsm/state-machine-library.md), is the component in charge of controlling the game flow. Each state corresponds to a game state, and game conditions trigger the different transitions of the FSM.

\[*] --> InitState InitState -> GameState : press key InitState --> \[*] : exit game GameState --> GameState GameState --> DeadState : health is 0 GameState --> \[*] : exit game DeadState --> GameState : respawn DeadState --> \[*] : exit game

note top of GameState Actual game occurs mostly here end note

There are three main states in `robotDevastation`, each of them with different pre-state, state and post-state conditions:

* [Init State](/robotdevastation-developer-manual/robotdevastation/game-fsm/init-state.md): the game starts in this state, showing the initial splash screen. When user is ready, it logs in the player.
* [Game State](/robotdevastation-developer-manual/robotdevastation/game-fsm/game-state.md): main state of the game. Combats and robot movement happen in this state.
* [Dead State](/robotdevastation-developer-manual/robotdevastation/game-fsm/dead-state.md): you arrive to this state when you die, and remain there for a certain amount of time until you can be respawned into the game.
