-
Notifications
You must be signed in to change notification settings - Fork 2
/
player.py
61 lines (50 loc) · 1.83 KB
/
player.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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
import random
import chen
class Player:
VERSION = "Default Python folding player"
MAX_BET = 300
def betRequest(self, game_state):
print (game_state)
in_action=game_state['in_action']
me=game_state['players'][in_action]
current_buy_in=game_state['current_buy_in']
cards = me['hole_cards']
self.rank1 = None
self.rank2 = None
if len(cards) > 1:
self.rank1 = cards[0]['rank']
self.rank2 = cards[1]['rank']
value = chen.get_value(cards)
if value < 8 and self.rank1 != 'A' and self.rank2 != 'A':
self.log_check()
return 0 # check only, no raise
if self.rank1 == self.rank2 and self.rank1 == 'A':
self.log_allin()
return 1000 # all in
minimum_raise = game_state['minimum_raise'] if 'minimum_raise' in game_state else 0
amount = current_buy_in - me['bet']
if amount > self.MAX_BET and self.rank1 != self.rank2:
print('CHECK only (HIGH bet)')
return 0 # fold
if len(cards) > 1:
r = minimum_raise + random.random()*10 if random.random()>0.3 else 0
amount += int(r)
self.log_call(amount)
return amount # always call
def showdown(self, game_state):
return True
def log_check(self):
if self.rank1:
print('{} {}: CHECK only'.format(self.rank1, self.rank2))
else:
print('CHECK only')
def log_call(self, amount):
if self.rank1:
print('{} {}: CALL: {}'.format(self.rank1, self.rank2, amount))
else:
print('CALL: {}'.format(amount))
def log_allin(self):
if self.rank1:
print('{} {}: ALL IN'.format(self.rank1, self.rank2))
else:
print('ALL IN')