backgammon/human.py

40 lines
1.2 KiB
Python
Raw Normal View History

2018-02-07 15:27:03 +00:00
class Human:
2018-02-07 14:31:05 +00:00
def __init__(self, board, sym, network):
self.network = network
2018-02-05 21:31:34 +00:00
self.board = board
self.sym = sym
def switch(self,cur):
return -1 if cur == 1 else 1
2018-02-05 21:31:34 +00:00
def get_sym(self):
return self.sym
2018-02-05 21:31:34 +00:00
def do_move(self, roll):
2018-02-07 15:27:03 +00:00
print(self.board.pretty())
2018-02-05 22:36:32 +00:00
print(self.board.find_legal_moves(self.sym,roll[0]))
2018-02-05 21:31:34 +00:00
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]))
2018-02-05 21:31:34 +00:00
2018-02-07 15:27:03 +00:00
print(self.board.pretty())
print(self.board.find_legal_moves(self.sym,roll[1]))
2018-02-05 21:31:34 +00:00
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]))