def update_enemy_graph(instance): """Updates each node with probability of enemy presence.""" regressions2.reset_graph(instance) known_enemies = get_known_enemies(instance) at_large_enemies = get_at_large_enemies(instance, known_enemies) #Find last known whereabouts and condition of each enemy bots at_large_enemies = account_for_spawns(instance, at_large_enemies) #Account for at large enemies list complete with last seen positions and times of all unseen enemies. bot_nodes_list = [] # Stores info on which bot accounted for which nodes. for enemy_bot_info in at_large_enemies: enemy_bot = enemy_bot_info[0] last_position = enemy_bot_info[1] time_of_position = enemy_bot_info[2] #Skip if the information is very stale. if instance.game.match.timePassed - time_of_position > 20.0: print "SKIPPING DATA THAT IS OUTDATED ON BOT %s" % enemy_bot.name continue #Based on these variables, calculate nodes that the bot could occupy. nodes = get_nodes_for_one_enemy(instance, enemy_bot, last_position, time_of_position) set_probability_density(instance, nodes, last_position, enemy_bot) bot_nodes_list.append((enemy_bot, nodes)) #Account for position and probability of all definitively known enemies. known_enemy_nodes = set() for enemy_bot in known_enemies: node_index = regressions2.get_node_index(instance, enemy_bot.position) known_enemy_nodes.add(node_index) instance.graph.node[node_index]["friendly_sight"] = True instance.graph.node[node_index]["p_enemy"] = 1.0 nodes = [node_index] bot_nodes_list.append((enemy_bot, nodes)) #Set sight and cone of fire data based on all nodes enemy_bots could be present in. #TODO - counts double for overlap squares... for enemy_bot, nodes in bot_nodes_list: set_fs_density(instance, nodes, enemy_bot)
def update_enemy_graph(instance): """Updates each node with probability of enemy presence.""" regressions2.reset_graph(instance) known_enemies = get_known_enemies(instance) at_large_enemies = get_at_large_enemies(instance, known_enemies) #Find last known whereabouts and condition of each enemy bots at_large_enemies = account_for_spawns(instance, at_large_enemies) #Account for at large enemies list complete with last seen positions and times of all unseen enemies. bot_nodes_list = [] # Stores info on which bot accounted for which nodes. for enemy_bot_info in at_large_enemies: enemy_bot = enemy_bot_info[0] last_position = enemy_bot_info[1] time_of_position = enemy_bot_info[2] #Skip if the information is very stale. if instance.game.match.timePassed - time_of_position > 20.0: print "SKIPPING DATA THAT IS OUTDATED ON BOT %s" % enemy_bot.name continue #Based on these variables, calculate nodes that the bot could occupy. nodes = get_nodes_for_one_enemy(instance, enemy_bot, last_position, time_of_position) set_probability_density(instance, nodes, last_position, enemy_bot) bot_nodes_list.append((enemy_bot, nodes)) #Account for position and probability of all definitively known enemies. known_enemy_nodes = set() for enemy_bot in known_enemies: node_index = regressions2.get_node_index(instance, enemy_bot.position) known_enemy_nodes.add(node_index) instance.graph.node[node_index]["friendly_sight"] = True instance.graph.node[node_index]["p_enemy"] = 1.0 nodes = [node_index] bot_nodes_list.append((enemy_bot, nodes)) #Set sight and cone of fire data based on all nodes enemy_bots could be present in. #TODO - counts double for overlap squares... for enemy_bot, nodes in bot_nodes_list: set_fs_density(instance, nodes, enemy_bot)
def update_enemy_graph(instance): regressions2.reset_graph(instance) known_enemies = get_known_enemies(instance) #Find last known whereabouts and condition of each enemy bots at_large_enemies = get_at_large_enemies(instance, known_enemies) #Get linear extrapolations of enemy movement bot_extraps = extrapolate(instance) store_enemy_positions(instance) #Account for at large enemies list complete with last seen positions and times of all unseen enemies. bot_nodes_list = [] # Stores info on which bot accounted for which nodes. for enemy_bot in at_large_enemies: #Skip if the information is very stale. if enemy_bot.seenlast > 25.0: continue #Based on these variables, calculate nodes that the bot could occupy. nodes = get_nodes_for_one_enemy(instance, enemy_bot) set_probability_density(instance, nodes, enemy_bot.position, enemy_bot, bot_extraps) bot_nodes_list.append((enemy_bot, nodes)) #Account for position and probability of all definitively known enemies. known_enemy_nodes = set() for enemy_bot in known_enemies: #Enemy could be at start of game. node_index = regressions2.get_node_index(instance, enemy_bot.position) known_enemy_nodes.add(node_index) instance.graph.node[node_index]["friendly_sight"] = True instance.graph.node[node_index]["p_enemy"] = 1.0 nodes = [node_index] bot_nodes_list.append((enemy_bot, nodes)) #Set sight and cone of fire data based on all nodes enemy_bots could be present in. for enemy_bot, nodes in bot_nodes_list: set_fs_density(instance, nodes, enemy_bot) print "DONE UPDATING ENEMY GRAPH"