示例#1
0
def evaluate_MCTS_against_winpct(data):
    ally_wins = 0
    enemy_wins = 0
    total_win_pct = 0
    ally_starting = data[0]
    exploration_term = data[1]
    state = MCTS.State()
    state.ally_starting = ally_starting

    tree = None

    banned_champs = set(random.sample(range(0, 141), 10))
    allowed_champions = MCTS.get_allowed_champions(banned_champs)
    while len(state.enemy_team) < 5 or len(state.ally_team) < 5:
        if ally_starting is not True:
            pick_champ_enemy_team_winpct(allowed_champions, state)
        tree = MCTS.recall_subtree(state, tree, set(banned_champs))
        allowed_champions = list.copy(tree.possible_actions)
        suggestions, tree = MCTS.run_mcts(10,
                                          tree,
                                          True,
                                          allowed_champions,
                                          exploration_term=exploration_term)

        if suggestions[0].champ2 is None:
            state.ally_team.append(suggestions[0].champ)
            allowed_champions.remove(suggestions[0].champ)
        else:
            state.ally_team.append(suggestions[0].champ)
            allowed_champions.remove(suggestions[0].champ)
            state.ally_team.append(suggestions[0].champ2)
            allowed_champions.remove(suggestions[0].champ2)
        if ally_starting is True:
            pick_champ_enemy_team_winpct(allowed_champions, state)
    input_vector = list.copy(state.ally_team)
    input_vector.extend(list.copy(state.enemy_team))
    result = NN.predictTeamComp(input_vector)
    total_win_pct += result
    if result > 0.5:
        ally_wins += 1
    elif result < 0.5:
        enemy_wins += 1

    return ally_wins, enemy_wins, result
示例#2
0
def test_get_allowed_champions2(test_input, already_chosen, expected):
    assert mcts.get_allowed_champions(test_input, already_chosen) == expected
示例#3
0
def test_get_allowed_champions(test_input, expected):
    assert mcts.get_allowed_champions(test_input) == expected