def run(): domino = Domino() domino.reset() pieces = domino.get_pieces() minimax = Minimax(pieces) first_state = minimax.first_state() value = minimax.find(first_state, -2, 2) print(value) print(len(minimax.memo_value))
def play(): import __init__ from domino import Domino my_team = 0 domino = Domino() domino.reset() pieces = domino.get_pieces() minimax = Minimax(pieces) state = minimax.first_state() while minimax.is_over(state) is None: mask, (h0, h1), player = state team = player & 1 if team == my_team: piece = get_move(state, pieces) else: print("Thinking...") value = minimax.find(state, -2, 2) # This is wrong, it depends on who starts the game if value > 0: print("I'm sure I'll win this game.") elif value == 0: print("If you play good this game is ties.") else: print("You've got a chance to win.") moves = minimax.memo_piece[state] print("This are my better moves:") print(moves) piece = None if len(moves) == 0 else moves[0] if piece is None: print(f"Player {player} passed.") else: print(f"Player {player} put {piece}") state = apply(state, piece, pieces)