35 lines
979 B
Python
35 lines
979 B
Python
from human import Human
|
|
from board import Board
|
|
from bot import Bot
|
|
from network import Network
|
|
from cup import Cup
|
|
|
|
class Game:
|
|
def __init__(self):
|
|
self.board = Board.initial_state
|
|
self.p1 = Human(1)
|
|
self.p2 = Bot(-1)
|
|
self.cup = Cup()
|
|
|
|
def roll(self):
|
|
return self.cup.roll()
|
|
|
|
def play(self):
|
|
while True:
|
|
roll = self.roll()
|
|
print("{} rolled: {}".format(self.p1.get_sym(), roll))
|
|
self.board = self.p1.do_move(self.board, roll)
|
|
if Board.is_winner(board, self.p1.get_sym()):
|
|
print("{} won!".format(self.p1.get_sym()))
|
|
break
|
|
|
|
roll = self.roll()
|
|
print("{} rolled: {}".format(self.p1.get_sym(), roll))
|
|
self.board = self.p2.do_move(self.board, roll)
|
|
if Board.is_winner(board, self.p2.get_sym()):
|
|
print("{} won!".format(self.p2.get_sym()))
|
|
break
|
|
|
|
g = Game()
|
|
g.play()
|