ROSE
ROSE copied to clipboard
Persist games
Currently when a game is played, the server generate a new game state on each cycle, and send the new state to all clients. Clients process the new state and send updates to the server. When the game is completed, the game history is lost.
If we would keep the game state, we could enable these use cases:
- Debugging a driver module, by playing back the game, possibly by moving forward or backward frame by frame.
- Keeping scoreboard with the best drivers ever played, and watching the games later
- Creating a competition management system, selecting players for games, selecting the winners for the next step, and so on.
- Having a playback UI, we can create a web demo, see #177
The simplest way to persist the game state is to keep a list of states on the server, and persist the list as json text when the game is completed. To playback a game, the web interface can load the game state list from the server, and playback the game.
We probably need additional metadata, we will work on it later.
Possible implementation:
- Add sqlite database to the server
- Add rose/server/db.py to access the database
- Keep game history list in rose/server/game.py. Once a game is started, append the game state once per game tick.
- When a game completes, create json text from the history list, and store in the database.
@rollandf can you review this proposal?