2018-02-05 21:31:34 +00:00
|
|
|
from hooman import Human
|
|
|
|
from board import Board
|
2018-02-05 22:50:31 +00:00
|
|
|
from bot import Bot
|
2018-02-05 21:31:34 +00:00
|
|
|
|
|
|
|
class Game:
|
|
|
|
|
|
|
|
def __init__(self):
|
|
|
|
self.board = Board()
|
2018-02-06 22:29:51 +00:00
|
|
|
self.p1 = Human(self.board, 1)
|
|
|
|
self.p2 = Bot(self.board, -1)
|
2018-02-05 21:31:34 +00:00
|
|
|
|
|
|
|
def play(self):
|
|
|
|
while True:
|
2018-02-05 22:50:31 +00:00
|
|
|
# print(self.board.to_s())
|
2018-02-05 21:31:34 +00:00
|
|
|
roll = self.p1.roll()
|
|
|
|
self.p1.do_move(roll)
|
2018-02-06 22:29:51 +00:00
|
|
|
if self.board.is_winner(self.p1.get_sym()):
|
|
|
|
print("{} won!".format(self.p1.get_sym()))
|
|
|
|
break
|
2018-02-05 22:50:31 +00:00
|
|
|
# print(self.board.to_s())
|
2018-02-05 21:31:34 +00:00
|
|
|
roll = self.p2.roll()
|
|
|
|
self.p2.do_move(roll)
|
2018-02-06 22:29:51 +00:00
|
|
|
if self.board.is_winner(self.p2.get_sym()):
|
|
|
|
print("{} won!".format(self.p2.get_sym()))
|
|
|
|
break
|
2018-02-05 21:31:34 +00:00
|
|
|
|
|
|
|
g = Game()
|
|
|
|
g.play()
|