バックエンドAPI

This commit is contained in:
2026-02-15 14:53:03 +09:00
commit fa86f555af
18 changed files with 2217 additions and 0 deletions

33
debug_dip.py Normal file
View File

@@ -0,0 +1,33 @@
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)