forked from facebookresearch/diplomacy_cicero
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrepro_agent.py
26 lines (23 loc) · 976 Bytes
/
repro_agent.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
#
# Copyright (c) Meta Platforms, Inc. and affiliates.
#
# This source code is licensed under the MIT license found in the
# LICENSE file in the root directory of this source tree.
#
import json
from fairdiplomacy.agents.base_agent import AgentState, BaseAgent, NoAgentState
from fairdiplomacy.pydipcc import Game
from fairdiplomacy.typedefs import Power
class ReproAgent(BaseAgent):
def __init__(self, game_path):
with open(game_path, "r") as f:
self.json = json.load(f)
def get_orders(self, game: Game, power: Power, state: AgentState):
assert isinstance(state, NoAgentState)
phase = game.get_state()["name"]
all_possible_orders_set = {
x for lst in game.get_all_possible_orders().values() for x in lst
}
orders = self.json["order_history"][phase].get(power, [])
assert set(orders).issubset(all_possible_orders_set), set(orders) - all_possible_orders_set
return list(orders)