-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathPlayers.py
50 lines (31 loc) · 975 Bytes
/
Players.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
'''
Erich Kramer - April 2017
Apache License
If using this code please cite creator.
'''
class Player:
def __init__(self, symbol):
self.symbol = symbol
#PYTHON: use obj.symbol instead
def get_symbol(self):
return self.symbol
#parent get_move should not be called
def get_move(self, board):
raise NotImplementedError()
class HumanPlayer(Player):
def __init__(self, symbol):
Player.__init__(self, symbol);
def clone(self):
return HumanPlayer(self.symbol)
#PYTHON: return tuple instead of change reference as in C++
def get_move(self, board):
row = int(input("Enter row:"))
col = int(input("Enter col:"))
return (col, row)
class MinimaxPlayer(Player):
def __init__(self, symbol):
Player.__init__(self, symbol);
if symbol == 'X':
self.oppSym = 'O'
else:
self.oppSym = 'X'