-
Notifications
You must be signed in to change notification settings - Fork 10
/
Copy pathgamereversi.py
38 lines (32 loc) · 1.19 KB
/
gamereversi.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
from __future__ import print_function
from reversigamelogic import ReversiGameLogic
def main():
game = ReversiGameLogic()
draw(game)
print("First move: ", game.whoseTurn())
while(game.getWinner() == 0):
canInput = True
while canInput:
#plays until someone wins
move_coordinate = raw_input\
("Input (row,col) for player %d or (8,8) to pass > "\
%game.whoseTurn())
#IF no legal move at all for a player, the optiion should be pass
#but it is not implemented as ReversiGameLogic ADT needs some change
r_string,c_string = move_coordinate.split(',')
r, c = int(r_string), int(c_string)
if game.isLegalMove(r,c):
canInput = False
game.makeMove(r,c)
draw(game)
def draw(game):
print ("r/c", end = ' ')
for a in range(8):
print (a, sep = ' ', end = ' ')
print ('\n')
for r in range(8):
print (r, sep = ' ', end = ' ')
for c in range(8):
print(game.occupiedBy(r,c), sep = ' ', end = ' ')
print('\n---------------------------------')
main()