Пример #1
0
def update_friendly_sight(instance):
    #Turn all cells currently seen by team to friendly_sight = True in graph.
    for bot in instance.game.team.members:
        if bot.health > 0.0:
            nodes = regressions2.one_bot_sees(instance, bot)
            for node_index in nodes:
                instance.graph.node[node_index]["friendly_sight"] = True
Пример #2
0
def update_friendly_sight(instance):
    #Turn all cells currently seen by team to friendly_sight = True in graph.
    for bot in instance.game.team.members:
        if bot.health > 0:
            nodes = regressions2.one_bot_sees(instance, bot)
            for node_index in nodes:
                instance.graph.node[node_index]["friendly_sight"] = True
Пример #3
0
def assign_single_node_fs_density(instance, source_node_id, enemy_bot):
    bot_position = regressions2.get_node_vector(instance, source_node_id)
    direction = get_direction(instance, enemy_bot)
    #If the bot is definitely dead (IE hasn't respawned etc...) don't bother filling in data about it.
    #Get direction returns a direction for just starting bots.
    if direction == None:
        return

    #Get all nodes visible to the hypothetical enemy bot, assign scores to them based on enemy sight and enemy firing capability.
    simulated_bot = {"position": bot_position, "direction": direction}
    visible_nodes = regressions2.one_bot_sees(instance, enemy_bot,
                                              simulated_bot)
    #TODO
    for node_index in visible_nodes:
        node_position = regressions2.get_node_vector(instance, node_index)
        #We care if about what probability the enemy is at the source node being evaluated.
        p_enemy = instance.graph.node[source_node_id]["p_enemy"]
        p_sight = instance.graph.node[node_index]["p_enemy_sight"]
        p_fire = instance.graph.node[node_index]["p_enemy_fire"]
        #TODO make fn to DRY this. #@FIRING
        #We purposefully overestimate their shooting range to have bots play cautiously.
        #We are also estimating at time of, which leaves lots of time for commands, hence the cone is not accurate.
        if (node_position -
                bot_position).length() < instance.level.firingDistance + 6:
            if p_fire == 0.0:
                instance.graph.node[node_index]["p_enemy_fire"] = p_enemy
            else:
                p_not_prior_fire = 1.0 - p_fire
                p_not_current_fire = 1.0 - p_enemy
                p_neither = p_not_prior_fire * p_not_current_fire
                final_prob_fire = 1.0 - p_neither
                instance.graph.node[node_index][
                    "p_enemy_fire"] = final_prob_fire

        if p_sight == 0.0:
            instance.graph.node[node_index]["p_enemy_sight"] = p_enemy
        else:
            p_not_prior_sight = 1.0 - p_sight
            p_not_current_sight = 1.0 - p_enemy
            p_neither = p_not_prior_sight * p_not_current_sight
            final_prob_sight = 1.0 - p_neither
            instance.graph.node[node_index]["p_enemy_sight"] = final_prob_sight
Пример #4
0
def assign_single_node_fs_density(instance, source_node_id, enemy_bot):
    bot_position = regressions2.get_node_vector(instance, source_node_id)
    direction = get_direction(instance, enemy_bot)
    #If the bot is definitely dead (IE hasn't respawned etc...) don't bother filling in data about it.
    #Get direction returns a direction for just starting bots.
    if direction == None:
        return
        
    #Get all nodes visible to the hypothetical enemy bot, assign scores to them based on enemy sight and enemy firing capability.
    simulated_bot = {"position": bot_position, "direction" : direction}
    visible_nodes = regressions2.one_bot_sees(instance, enemy_bot, simulated_bot)
    #TODO
    for node_index in visible_nodes:
        node_position = regressions2.get_node_vector(instance, node_index)
        #We care if about what probability the enemy is at the source node being evaluated.
        p_enemy = instance.graph.node[source_node_id]["p_enemy"]
        p_sight = instance.graph.node[node_index]["p_enemy_sight"]
        p_fire = instance.graph.node[node_index]["p_enemy_fire"]
        #TODO make fn to DRY this. #@FIRING
        #We purposefully overestimate their shooting range to have bots play cautiously.
        #We are also estimating at time of, which leaves lots of time for commands, hence the cone is not accurate.
        if (node_position - bot_position).length() < instance.level.firingDistance + 6:
            if p_fire == 0.0:
                instance.graph.node[node_index]["p_enemy_fire"] = p_enemy
            else:
                p_not_prior_fire = 1.0 - p_fire
                p_not_current_fire = 1.0 - p_enemy
                p_neither = p_not_prior_fire * p_not_current_fire
                final_prob_fire = 1.0 - p_neither
                instance.graph.node[node_index]["p_enemy_fire"] = final_prob_fire
                
        if p_sight == 0.0:
            instance.graph.node[node_index]["p_enemy_sight"] = p_enemy
        else:
            p_not_prior_sight = 1.0 - p_sight
            p_not_current_sight = 1.0 - p_enemy
            p_neither = p_not_prior_sight * p_not_current_sight
            final_prob_sight = 1.0 - p_neither
            instance.graph.node[node_index]["p_enemy_sight"] = final_prob_sight