-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsaboteur_environment.py
39 lines (28 loc) · 1.32 KB
/
saboteur_environment.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
27
28
29
30
31
32
33
34
35
36
37
38
39
from saboteur_base_environment import SaboteurBaseEnvironment
from card import PathCard, ActionCard
class SaboteurEnvironment(SaboteurBaseEnvironment):
def __init__(self):
super().__init__()
def get_legal_actions(game_state):
legal_actions = []
#game_board = game_state['game-board']
#player_turn = SaboteurBaseEnvironment.turn(game_state)
player_card = SaboteurBaseEnvironment.get_hand_cards()
for x in range(20):
for y in range(20):
if SaboteurBaseEnvironment.is_empty(x, y) and SaboteurBaseEnvironment.is_adjacent_to_tunnel(x, y):
for card in player_card:
if isinstance(card, PathCard):
legal_actions.append(f'use-path-card-{card}-{x}-{y}')
print(legal_actions)
return legal_actions
def get_winner(game_state):
game_board = game_state['game-board']
if SaboteurBaseEnvironment._all_cards_played() == True or len(SaboteurEnvironment.get_legal_actions() == 0):
return "Saboteur"
if SaboteurBaseEnvironment._path_connected() == True:
return "Gold-Diggers"
return None
def is_terminal(game_state):
if SaboteurEnvironment.get_winner(game_state) is not None:
return True