forked from facebookresearch/diplomacy_cicero
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrandom_agent.py
26 lines (21 loc) · 818 Bytes
/
random_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 random
from fairdiplomacy.pydipcc import Game
from fairdiplomacy.typedefs import Power
from .base_agent import AgentState, BaseAgent, NoAgentState
class RandomAgent(BaseAgent):
def __init__(self, cfg):
del cfg # Not used.
def get_orders(self, game: Game, power: Power, state: AgentState):
assert isinstance(state, NoAgentState)
possible_orders = {
loc: orders
for loc, orders in game.get_all_possible_orders().items()
if loc in game.get_orderable_locations()[power]
}
return [random.choice(orders) for orders in possible_orders.values()]