-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathGameEngine.py
More file actions
22 lines (21 loc) · 814 Bytes
/
GameEngine.py
File metadata and controls
22 lines (21 loc) · 814 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
class GameEngine:
def play_game(self,board,player1,player2,print_moves=False):
win = False
while True:
selectedCol = player1.play(board.available_columns())
win = board.add_to_col(selectedCol,player1.color)
if win:
break
if print_moves:
board.print_board()
print()
selectedCol = player2.play(board.available_columns())
win = board.add_to_col(int(selectedCol), player2.color)
if win or len(board.available_columns())==0:
break
if print_moves:
board.print_board()
print()
print('The winner is: {0} - '.format(board.winner) ,end='')
print(board.winner)
return