36 lines
998 B
Python
36 lines
998 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()
|
|
self.network = Network()
|
|
self.p1 = Human(self.board, 1, self.network)
|
|
self.p2 = Bot(self.board, -1, self.network)
|
|
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.p1.do_move(roll)
|
|
if self.board.is_winner(self.p1.get_sym()):
|
|
print("{} won!".format(self.p1.get_sym()))
|
|
break
|
|
|
|
roll = self.roll()
|
|
print("{} rolled: {}".format(self.p1.get_sym(), roll))
|
|
self.p2.do_move(roll)
|
|
if self.board.is_winner(self.p2.get_sym()):
|
|
print("{} won!".format(self.p2.get_sym()))
|
|
break
|
|
|
|
g = Game()
|
|
g.play()
|