コード例 #1
0
ファイル: DPFReport.py プロジェクト: 30to1/aa_report
def _get_fight_costs( games, max_frame_gap, ignore_end_frames, limit_ratio_change_mult ):
    game_fights = {}
    game_fight_player_costs = {}
    game_fight_net_costs = {}
    game_fight_player_dpf = {}

    for game in games:
        fights, fight_player_costs,fight_net_costs,fight_player_dpf = [],[],[],[]

        game_fights[game.game_id] = fights
        game_fight_player_costs[game.game_id] = fight_player_costs
        game_fight_net_costs[game.game_id] = fight_net_costs
        game_fight_player_dpf[game.game_id] = fight_player_dpf

        for fight in FightUtils.iter_fights(game, max_frame_gap):
            fights.append(fight)
            # fetch the fight_participant's
            final_frame = game.aa_list[ len(game.aa_list)-1].died_frame - ignore_end_frames
            born,rein,dead = FightUtils.get_fight_participants(game,fight, final_frame)

            player_costs = Costs.get_player_fight_costs(game, fight, ignore_end_frames, born=born, rein=rein, dead=dead)
            net_costs = Costs.NetFightCosts(player_costs[0], player_costs[1], limit_ratio_change_mult)

            player_dpf = get_player_dpf( dead )
            # dpf presented relative to 'reference_player'. This excludes team games.
            if net_costs.army_ratio and net_costs.reference_player_index == 1:
                player_dpf[0], player_dpf[1] = player_dpf[1], player_dpf[0]
            fight_player_dpf.append(player_dpf)

            fight_player_costs.append(player_costs)
            fight_net_costs.append(net_costs)

    return game_fights, game_fight_player_costs, game_fight_net_costs, game_fight_player_dpf
コード例 #2
0
ファイル: ArmyRatioReport.py プロジェクト: 30to1/aa_report
def _get_fight_costs( games, max_frame_gap, ignore_end_frames, limit_ratio_change_mult ):
    game_fights = {}
    game_fight_player_costs = {}
    game_fight_net_costs = {}

    for game in games:
        fights, fight_player_costs,fight_net_costs = [],[],[]

        game_fights[game.game_id] = fights
        game_fight_player_costs[game.game_id] = fight_player_costs
        game_fight_net_costs[game.game_id] = fight_net_costs
        for fight in FightUtils.iter_fights(game, max_frame_gap):
            fights.append(fight)
            player_costs = Costs.get_player_fight_costs(game,fight, ignore_end_frames, born=None, rein=None, dead=None)
            net_costs = Costs.NetFightCosts(player_costs[0], player_costs[1], limit_ratio_change_mult)

            fight_player_costs.append(player_costs)
            fight_net_costs.append(net_costs)

    return game_fights, game_fight_player_costs, game_fight_net_costs
コード例 #3
0
ファイル: Costs.py プロジェクト: 30to1/aa_report
def get_player_fight_costs(game, fight, ignore_end_frames, born = None, rein = None, dead = None):

    if not (born and rein and dead):
        final_frame = game.aa_list[ len(game.aa_list)-1].died_frame - ignore_end_frames
        born,rein,dead = FightUtils.get_fight_participants(game,fight, final_frame)

    # this method gets called around 100,000 times in 10k games
    # run time is aprox 45 seconds
    #   - 35 of which is get_fight_participants
    #   - 3 of which is sum, 5 of which is generator
    # get_fight_participants loops through every unit in game per call. Total loop iter ~ 23 million for this set.

    p1_born = sum( aa.simple_cost for aa in born if aa.player_index == 0 )
    p2_born = sum( aa.simple_cost for aa in born if aa.player_index == 1 )

    p1_rein = sum( aa.simple_cost for aa in rein if aa.player_index == 0 )
    p2_rein = sum( aa.simple_cost for aa in rein if aa.player_index == 1 )

    p1_dead = sum( aa.simple_cost for aa in dead if aa.player_index == 0 )
    p2_dead = sum( aa.simple_cost for aa in dead if aa.player_index == 1 )

    return [PlayerFightCosts(game.game_id, player_index=0, start_cost=p1_born, rein_cost=p1_rein, dead_cost=p1_dead),
            PlayerFightCosts(game.game_id, player_index=1, start_cost=p2_born, rein_cost=p2_rein, dead_cost=p2_dead)]