-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathuser_player.py
executable file
·95 lines (77 loc) · 3.34 KB
/
user_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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
from abstract_player import AbstractPlayer
# class that represents user controlled user
class UserPlayer(AbstractPlayer):
def __init__(self, name):
AbstractPlayer.__init__(self, name)
# ===========================================================================
# #UPDATE:
# ===========================================================================
def update(self, gamestate):
# =======================================================================
# #GAMESTATE ANALYSIS
# =======================================================================
# MONEY:
money = self.getMoney()
# IDENTIFY TOCALL:
tocall = gamestate.get_player_bet_difference(self)
if not self.allin:
print'////////////////////////////////'
print '%s :' % (self.getName())
print
if gamestate.get_cards_on_table() != []:
print gamestate.displayCards()
print 'Your hand is %s' % (self.getHand())
print '%s has to call %s' % (self.getName(), tocall)
print
# POSSIBLE ACTIONS:
if tocall == 0:
possibleactions = 'Fold, Check, Bet, Allin'
act = ['F', 'H', 'B', 'A']
elif tocall < money:
possibleactions = 'Fold, Call, Raise, Allin'
act = ['F', 'C', 'R', 'A']
elif tocall >= money:
possibleactions = 'Fold, Allin'
act = ['F', 'A']
print 'Possible actions are: %s' % (possibleactions)
print 'Press F to Fold, H to check, C to call, B to bet, R to raise, A to bet Allin'
print
imput = raw_input('Please choose an action: ')
print
while imput not in act:
print 'Selcted wrong key:'
imput = raw_input('Please choose an action: ')
if imput == 'F':
self.fold(gamestate)
elif imput == 'H':
self.check(gamestate)
elif imput == 'C':
self.call(gamestate)
elif imput == 'A':
self.allIn(gamestate)
elif imput == 'R':
maxa = money - tocall
print 'Maximum of raise is %s' % (maxa)
valuee = raw_input('please imput a value')
valuee = int(valuee)
while valuee > maxa:
valuee = raw_input('please imput a value')
valuee = int(valuee)
if valuee == maxa:
self.allIn(gamestate)
else:
self.bet(gamestate, tocall + valuee)
elif imput == 'B':
maxa = money
print 'Maximum of bet is %s' % (maxa)
valuee = raw_input('please imput a value')
valuee = int(valuee)
while valuee > maxa:
valuee = raw_input('please imput a value')
valuee = int(valuee)
if valuee == maxa:
self.allIn(gamestate)
else:
self.bet(gamestate, tocall + valuee)
print'////////////////////////////////'
print