dump / restore game state to / from json.
See original GitHub issueThis is a feature request
It would be nice to see a simple api to dump game state to json and restore it. Something like
let json = game.dump()
game.restore(json)
This could be used to save games in a database or create save/restore points.
Issue Analytics
- State:
- Created 6 years ago
- Reactions:1
- Comments:7 (3 by maintainers)
Top Results From Across the Web
Support saving game state · Issue #18 · bfirsh/jsnes-web · GitHub
Dump snapshot of whole emulator to JSON and restore. See bfirsh/jsnes#16 for existing issue and bfirsh/jsnes#42 for existing implementation.
Read more >How can I save the state of my bot's activity with json?
import json, pickle with open('BOT_STATE_NAME.pkl', 'w') as fp: json.dump(sample, fp). Then, when your bot will be changing it`s state, ...
Read more >Save and load Python data with JSON - Opensource.com
Meanwhile, the JSON module's dump function is used to dump the data from the dict into the data file. Saving data from your...
Read more >JSON – Logic_bot - Oregon State University
Finally we can use json.dump() to send the formatted string to the file that ... saved pretend we are starting a new instance...
Read more >Python Tutorial: json.dump(s) & json.load(s) - 2021
json.load(s) & json.dump(s). python-json-load-loads-dump-dumps.png. There are two ways of reading in (load/loads) the following json file, in.json:
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@Piterden - thank you for sharing! It looks like you’re saving each move into a table and then restoring the board by re-applying each move individually. This is effectively what I did in the stdlib implementation.
An alternative, I recently noticed, which I forgot about in my original reply on this issue thread, that there is a way to load a game from a move history: https://github.com/brozeph/node-chess/blob/master/src/game.js#L86. One possibility might be to serialize the move history as JSON (
JSON.stringify(gameClient.game.moveHistory)
) and then use that when creating a game subsequently for reload… if this sounds interesting or worthwhile, I could implement aload
method from the game clients that does just this (as an alternative to thecreate
method).Should we keep this issue open, or does the FEN load address this need?