34 lines
1023 B
Python
34 lines
1023 B
Python
from diplomacy import Game
|
|
import json
|
|
|
|
game = Game()
|
|
# Spring 1901 Movement
|
|
print(f"Initial Phase: {game.phase}")
|
|
# print(f"Available methods: {[m for m in dir(game) if not m.startswith('_')]}")
|
|
|
|
# Set some orders
|
|
game.set_orders("AUSTRIA", ["A BUD - VIE", "F TRI - ADR", "A VIE - TRI"])
|
|
game.process()
|
|
|
|
|
|
print(f"\nAfter process Phase: {game.phase}")
|
|
print(f"After process History Keys: {list(game.state_history.keys())}")
|
|
|
|
d = game.to_dict()
|
|
|
|
# Simulate a new request loading from the dict
|
|
print("\n--- Loading from Dict in a NEW Game object ---")
|
|
new_game = Game()
|
|
new_game.from_dict(d)
|
|
|
|
print(f"New Game Phase: {new_game.phase}")
|
|
print(f"New Game Units (AUSTRIA): {new_game.get_units('AUSTRIA')}")
|
|
|
|
possibilities = new_game.get_all_possible_orders()
|
|
austria_locs = [u.split(' ')[1] for u in new_game.get_units('AUSTRIA')]
|
|
austria_possibilities = {loc: orders for loc, orders in possibilities.items() if loc in austria_locs}
|
|
|
|
print(f"\nPossible Orders for AUSTRIA units ({austria_locs}):")
|
|
print(austria_possibilities)
|
|
|