Ejemplo n.º 1
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)
Ejemplo n.º 2
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