-
Notifications
You must be signed in to change notification settings - Fork 6
/
randomplayer.py
43 lines (35 loc) · 1.31 KB
/
randomplayer.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
40
41
42
43
from pypokerengine.players import BasePokerPlayer
import random as rand
import pprint
class RandomPlayer(BasePokerPlayer):
def declare_action(self, valid_actions, hole_card, round_state):
# valid_actions format => [raise_action_pp = pprint.PrettyPrinter(indent=2)
#pp = pprint.PrettyPrinter(indent=2)
#print("------------ROUND_STATE(RANDOM)--------")
#pp.pprint(round_state)
#print("------------HOLE_CARD----------")
#pp.pprint(hole_card)
#print("------------VALID_ACTIONS----------")
#pp.pprint(valid_actions)
#print("-------------------------------")
r = rand.random()
if r <= 0.5:
call_action_info = valid_actions[1]
elif r<= 0.9 and len(valid_actions ) == 3:
call_action_info = valid_actions[2]
else:
call_action_info = valid_actions[0]
action = call_action_info["action"]
return action # action returned here is sent to the poker engine
def receive_game_start_message(self, game_info):
pass
def receive_round_start_message(self, round_count, hole_card, seats):
pass
def receive_street_start_message(self, street, round_state):
pass
def receive_game_update_message(self, action, round_state):
pass
def receive_round_result_message(self, winners, hand_info, round_state):
pass
def setup_ai():
return RandomPlayer()