backgammon/human.py

40 lines
1.2 KiB
Python

class Human:
def __init__(self, board, sym, network):
self.network = network
self.board = board
self.sym = sym
def switch(self,cur):
return -1 if cur == 1 else 1
def get_sym(self):
return self.sym
def do_move(self, roll):
print(self.board.pretty())
print(self.board.find_legal_moves(self.sym,roll[0]))
cur_state = self.board.get_state()
print("What to do with the first roll?")
cmds_1 = input().split(",")
while not self.board.check_move(cmds_1, self.sym, roll[0]):
print("Invalid move, try again.")
cmds_1 = input().split(",")
self.board.move_thing(self.sym, int(cmds_1[0]), int(cmds_1[1]))
print(self.board.pretty())
print(self.board.find_legal_moves(self.sym,roll[1]))
print("What to do with the second roll?")
cmds_2 = input().split(",")
while not self.board.check_move(cmds_2, self.sym, roll[1]):
print("Invalid move")
cmds_2 = input().split(",")
self.board.move_thing(self.sym, int(cmds_2[0]), int(cmds_2[1]))