forked from HerrMotz/marjapussi-ki
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathpolicy2.py
26 lines (18 loc) · 798 Bytes
/
policy2.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
import math
import random as rnd
from pprint import pprint
from marjapussi.policy import Policy
class AlwaysProvokePolicy(Policy):
def __init__(self) -> None:
super().__init__()
self.beliefs = {}
def _action_string(self, state, action, value):
return f'{state["player_num"]},{action},{value}'
def select_action(self, state, legal_actions) -> str:
game_phase = legal_actions[0].split(',')[1] == 'PROV'
if game_phase == 'PROV':
# if you have an ace (no matter what else you have)
# you can provoke +5
# do not provoke 5 if your partner has an ace
return self._action_string(state, 'PROV', state['game_value']+5)
return rnd.choice(legal_actions[:int(math.ceil(len(legal_actions)/2))])