コード例 #1
0
    board_mat, last_play_color, last_play_xcoordinate, last_play_ycoordinate = \
        boardState()
    if last_play_xcoordinate is not None:
        last_move = (last_play_xcoordinate, last_play_ycoordinate)
    else:
        last_move = None
    board_copy = deepcopy(board_mat)

    # Decide how to play using random_Player
    """
    my_color, my_move, info = \
        random_player(board_mat, last_move, get_empty_positions(board_mat))
    """
    player = MCTS(400)
    my_color, my_move, info = \
        player.play(board_mat, last_move, get_empty_positions(board_mat))
    """
    assert board_mat == board_copy, "The board has changed!"
    assert my_move in get_empty_positions(board_copy), \
        "I interface detect an illegal move!!!"
    """

    my_x_coordinate = my_move[0]
    my_y_coordinate = my_move[1]

    # Output the result
    modifyBoard(board_mat, my_color, my_x_coordinate, my_y_coordinate)
    """
    boardState()

    board_mat = [[-1, -1, -1, -1, -1, -1, -1, -1], [1, 3, -1, -1, -1, -1, -1, -1], [3, 0, 2, -1, -1, -1, -1, -1], [1, 0, 0, 3, -1, -1, -1, -1], [3, 1, 0, 0, 2, -1, -1, -1], [1, 0, 0, 0, 0, 3, -1, -1], [3, 0, 0, 0, 0, 0, 2, -1], [-1, 1, 2, 1, 2, 1, 2, -1]]
コード例 #2
0
 def test_evaluation_None0(self):
     board = deepcopy(self.board)
     board[3][1] = 1
     empty = get_empty_positions(board)
     self.assertEqual(random_evaluation(board, None, False, empty, 10), -10)
コード例 #3
0
ファイル: mixPlayer.py プロジェクト: RuoxiQin/Minmax-Game
        left) + "," + str(right) + ")"
    sys.stdout.write(myMove)


if __name__ == "__main__":
    # Get the board state
    board_mat, last_play_color, last_play_xcoordinate, last_play_ycoordinate = \
        boardState()
    if last_play_xcoordinate is not None:
        last_move = (last_play_xcoordinate, last_play_ycoordinate)
    else:
        last_move = None
    board_copy = deepcopy(board_mat)

    # Decide how to play using random_Player
    empty_positions = get_empty_positions(board_mat)
    if len(empty_positions) > 4:
        player = MCTS(400)
        my_color, my_move, info = \
            player.play(board_mat, last_move, empty_positions)
    else:
        player = MinmaxPlayer(5, 30)
        my_color, my_move, info = \
            player.play(board_mat, last_move, empty_positions)

    my_x_coordinate = my_move[0]
    my_y_coordinate = my_move[1]

    # Output the result
    modifyBoard(board_mat, my_color, my_x_coordinate, my_y_coordinate)
コード例 #4
0
 def test_evaluation_1(self):
     board = deepcopy(self.board)
     board[3][1] = 1
     empty = get_empty_positions(board)
     self.assertEqual(random_evaluation(board, (3, 1), True, empty, 10), 10)