aboutsummaryrefslogtreecommitdiff
path: root/README.md
diff options
context:
space:
mode:
authorPhilip Paquette <pcpaquette@gmail.com>2019-09-11 18:04:23 -0400
committerPhilip Paquette <pcpaquette@gmail.com>2019-09-14 18:18:53 -0400
commita6da1964e1d86217eb2be103a7008fc18904869f (patch)
tree20e0697be83218ed4431bba978721b012262321f /README.md
parent3b9406f74f265e1ce13967e0be6117269569018e (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.md7
1 files changed, 3 insertions, 4 deletions
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