From a6da1964e1d86217eb2be103a7008fc18904869f Mon Sep 17 00:00:00 2001 From: Philip Paquette Date: Wed, 11 Sep 2019 18:04:23 -0400 Subject: to_saved_game_format - Added 'output_path' and 'output_mode' - Game can now be saved (appended) to disk in one line --- README.md | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) (limited to 'README.md') diff --git a/README.md b/README.md index 247893e..df2c4e1 100644 --- a/README.md +++ b/README.md @@ -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 -- cgit v1.2.3