backgammon/game.py

32 lines
851 B
Python

from hooman import Human
from board import Board
from bot import Bot
from network import Network
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)
def play(self):
while True:
# print(self.board.to_s())
roll = self.p1.roll()
self.p1.do_move(roll)
if self.board.is_winner(self.p1.get_sym()):
print("{} won!".format(self.p1.get_sym()))
break
# print(self.board.to_s())
roll = self.p2.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()