예제 #1
0
def test_team_updates_traits_on_battle_start():
    s_warrior = pd.Series([90, 90, 90, "衝鋒,先驅,氣勢,副將,波狀攻擊,名將"],
                          index=["統率", "武勇", "智略", "類型戰鬥特性"])
    team = Team(s_warrior, 10000)
    opponent = Team(s_opponent1, 10000)
    team.set_opponent(opponent)
    team.traits.loc[:, "activation_rate"] = 1.0

    expected = team.traits.copy()
    expected.loc[expected["name"].isin(["衝鋒", "先驅"]), "activated"] = True

    team.update_traits_on_battle_start()
    print(team.traits)
    print(expected)
    print(team.traits.dtypes)
    print(expected.dtypes)

    assert pd.DataFrame.equals(team.traits, expected)
예제 #2
0
def run_evaluation():
    log = init_log()
    total = df_candidates.shape[0]

    for idx, candidate in df_candidates.iterrows():
        idx = idx + 1
        msg = f"{idx}/{total}"
        for battle in range(1, 101):
            team = Team([candidate], 5000)
            opponent = Team([s_opponent], 5000)
            team.set_opponent(opponent)
            opponent.set_opponent(team)

            tik = 1
            while team.troops > 0 and opponent.troops > 0:
                team.update_traits_on_tik_start()
                opponent.update_traits_on_tik_start()
                if tik % 3 == 0:
                    team.update_traits_on_battle_start()
                    opponent.update_traits_on_battle_start()
                    team.update_team_factors()
                    opponent.update_team_factors()

                    kills = team.calculate_kills()
                    killed = opponent.calculate_kills()
                    team.take_damage(killed)
                    opponent.take_damage(kills)

                    log = battle_log(log, battle, tik, team, opponent, kills,
                                     killed, msg)

                    team.update_traits_on_battle_end()
                    opponent.update_traits_on_battle_end()

                team.update_traits_on_tik_end()
                opponent.update_traits_on_tik_end()

                tik = tik + 1

            log.to_excel("battle_log.xlsx", index=False)
예제 #3
0
def test_battle():
    log = init_log()

    team = Team([s_wutianxinxuan], 10000)
    opponent = Team([s_shangshanqianxin], 10000)

    team.set_opponent(opponent)
    opponent.set_opponent(team)

    tik = 1
    while team.troops > 0 and opponent.troops > 0:
        team.update_traits_on_tik_start()
        opponent.update_traits_on_tik_start()
        if tik % 3 == 0:
            team.update_traits_on_battle_start()
            opponent.update_traits_on_battle_start()

            team.update_team_factors()
            opponent.update_team_factors()

            kills = team.calculate_kills()
            killed = opponent.calculate_kills()

            team.take_damage(killed)
            opponent.take_damage(kills)

            log = battle_log(log, tik, team, opponent, kills, killed)

            team.update_traits_on_battle_end()
            opponent.update_traits_on_battle_end()

        team.update_traits_on_tik_end()
        opponent.update_traits_on_tik_end()

        tik = tik + 1

    log.to_excel("battle_log.xlsx", index=False)

    assert True