-
Notifications
You must be signed in to change notification settings - Fork 1
/
Game.py
35 lines (29 loc) · 1.01 KB
/
Game.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
from board import *
class Game:
def __init__(self, player_1, player_2):
self.board = Board(GAME_ROWS, GAME_COLS)
# make sure the players start from scratch
player_1.reset()
player_2.reset()
self.player_1 = player_1
self.player_2 = player_2
# go through the game and return the winner
def play(self, verbose):
if verbose:
self.board.print_board()
while True:
# player 1 is always the first one to move
self.board.place_stone(self.player_1.move(self.board))
if verbose:
self.board.print_board()
winner = self.board.status
if winner != NOT_TERMINATED:
break
# then comes player 2
self.board.place_stone(self.player_2.move(self.board))
if verbose:
self.board.print_board()
winner = self.board.status
if winner != NOT_TERMINATED:
break
return winner