def heuristic(game: ReversiGame, heuristic_list: list[list[int]]) -> float: """ heuristic takes a given heuristic_list and returns the game-state value given by the list """ if game.get_winner() is None: pieces = game.get_board().pieces black = 0 white = 0 length = len(pieces) for i in range(length): for m in range(length): if pieces[i][m] == 1: black += heuristic_list[i][m] elif pieces[i][m] == -1: white += heuristic_list[i][m] return white - black elif game.get_winner() == 'white': return 100000 elif game.get_winner() == 'black': return -100000 else: return 0
winner = game.get_winner() if winner is not None: results.append(winner) ui_handler.update_games_stored_text(len(results), window) increment_player_score(winner, window) game.start_game(human_player=game.get_human_player()) # If the game is not paused, look for mouse clicks and process moves. if not ui_handler.get_game_paused(): if game.get_human_player() == game.get_current_player(): # Look at the mouse clicks and see if they are in the board. for event in window.get_events(): if event[0] == pygame.MOUSEBUTTONUP: square = board_manager.check_mouse_press( event[1], game.get_board()) if square != (-1, -1): if game.try_make_move(square): moves_made.append(square) elif game.get_winner() is None: next_move = colour_to_player[ game.get_current_player()].make_move(game, moves_made[-1]) game.try_make_move(next_move) moves_made.append(next_move) # Update the window's clock window.update_clock() """ DRAW STUFF """ # Draw the background first!!!! window.draw_background()