diff options
author | Philip Paquette <pcpaquette@gmail.com> | 2019-09-11 18:04:23 -0400 |
---|---|---|
committer | Philip Paquette <pcpaquette@gmail.com> | 2019-09-14 18:18:53 -0400 |
commit | a6da1964e1d86217eb2be103a7008fc18904869f (patch) | |
tree | 20e0697be83218ed4431bba978721b012262321f /README.md | |
parent | 3b9406f74f265e1ce13967e0be6117269569018e (diff) |
to_saved_game_format - Added 'output_path' and 'output_mode'
- Game can now be saved (appended) to disk in one line
Diffstat (limited to 'README.md')
-rw-r--r-- | README.md | 7 |
1 files changed, 3 insertions, 4 deletions
@@ -27,7 +27,6 @@ The package is compatible with Python 3.5, 3.6, and 3.7. The following script plays a game locally by submitting random valid orders until the game is completed. ```python3 -import json import random from diplomacy import Game from diplomacy.utils.export import to_saved_game_format @@ -56,9 +55,9 @@ while not game.is_game_done: # Processing the game to move to the next phase game.process() -# Exporting the game to disk to visualize -with open('game.json', 'w') as file: - file.write(json.dumps(to_saved_game_format(game))) +# Exporting the game to disk to visualize (game is appended to file) +# Alternatively, we can do >> file.write(json.dumps(to_saved_game_format(game))) +to_saved_game_format(game, output_path='game.json') ``` ## Web interface |