示例#1
0
def account_for_spawns(instance, at_large_enemies):
    #Updates positions of enemies whose health is ostensibly 0 based on if they have respawned.
    #Dead enemies that have respawned still appear as health 0, and are very much a threat!
    for enemy_info in at_large_enemies:
        if enemy_info[0].health == 0 or None:
            #See if bot has respawned since it was killed.
            respawned_time = get_respawn(instance, enemy_info[0])
            #If the bot respawned figure count its last seen as the center of its respawn.
            if respawned_time != None:
                enemy_spawn_coord = Vector2.midPoint(instance.game.enemyTeam.botSpawnArea[0], instance.game.enemyTeam.botSpawnArea[1])
                enemy_info[1] = enemy_spawn_coord
                enemy_info[2] = instance.game.match.timePassed - respawned_time + .5
            #If the bot is respawning in the next two seconds, count its last seen as the center of its respawn.
            elif instance.game.match.timeToNextRespawn < 2.00:
                enemy_spawn_coord = Vector2.midPoint(instance.game.enemyTeam.botSpawnArea[0], instance.game.enemyTeam.botSpawnArea[1])
                enemy_info[1] = enemy_spawn_coord
                enemy_info[2] = 2.0
            #If the game has just begun and the bot is chilling in his spawn, assign him as there. #TODO better spawn positioning.
            elif enemy_info[0].state == 0:
                enemy_spawn_coord = Vector2.midPoint(instance.game.enemyTeam.botSpawnArea[0], instance.game.enemyTeam.botSpawnArea[1])
                enemy_info[1] = enemy_spawn_coord
                enemy_info[2] = -1.5 #This is a hack so that we evaluate enemy bots as present at the start. It works pretty well.
            #If none of the above are true, the bot is dead and we don't need to worry about him.
            else:
                at_large_enemies.remove(enemy_info)
##    print at_large_enemies
    return at_large_enemies
示例#2
0
def get_direction(instance, enemy_bot):
    #TODO have this account for potentially changing directions.
    direction = None
    if enemy_bot.health == 0 or None:
        #See if bot has respawned since it was killed.
        respawned_time = get_respawn(instance, enemy_bot)
        #If the bot respawned, is about to respawn, or has state_unknown, assume it is in its spawn and facing the closest of our bots.
        if respawned_time != None or instance.game.match.timeToNextRespawn < 2.00 or enemy_bot.state == 0:
            spawn_position = Vector2.midPoint(
                instance.game.enemyTeam.botSpawnArea[0],
                instance.game.enemyTeam.botSpawnArea[1])
            our_bot_positions = [
                bot.position for bot in instance.game.team.members
            ]
            closest = float("inf")
            closest_point = None
            for position in our_bot_positions:
                distance = (position - spawn_position).length()
                if distance < closest:
                    closest_point = position
                    closest = distance
            direction = closest_point - spawn_position
        else:
            #Enemy is dead and hasn't respawned, return no probability for look directions.
            return None

    #If the enemy bot is alive, use its last known orientation to figure out where it is aiming.
    else:
        direction = enemy_bot.facingDirection
    return direction
示例#3
0
def get_direction(instance, enemy_bot):
    #TODO have this account for potentially changing directions.
    direction = None
    if enemy_bot.health == 0 or None:
        #See if bot has respawned since it was killed.
        respawned_time = get_respawn(instance, enemy_bot)
        #If the bot respawned, is about to respawn, or has state_unknown, assume it is in its spawn and facing the closest of our bots.
        if respawned_time != None or instance.game.match.timeToNextRespawn < 2.00 or enemy_bot.state == 0:
            spawn_position = Vector2.midPoint(instance.game.enemyTeam.botSpawnArea[0], instance.game.enemyTeam.botSpawnArea[1])
            our_bot_positions = [bot.position for bot in instance.game.team.members]
            closest = float("inf")
            closest_point = None
            for position in our_bot_positions:
                distance = (position - spawn_position).length()
                if distance < closest:
                    closest_point = position
                    closest = distance
            direction = closest_point - spawn_position
        else:
            #Enemy is dead and hasn't respawned, return no probability for look directions.
            return None
        
    #If the enemy bot is alive, use its last known orientation to figure out where it is aiming.
    else:
        direction = enemy_bot.facingDirection
    return direction
示例#4
0
def get_at_large_enemies(instance, known_enemies):
    #List enemies without 100% certainty of location.
    #Format is bot, last known position.
    unknown_enemies = []
    for enemy_bot in instance.game.enemyTeam.members:
        if enemy_bot not in known_enemies and enemy_bot not in unknown_enemies:
            if enemy_bot.seenlast == None:
                time_seen = 0.0
                position = Vector2.midPoint(instance.game.enemyTeam.botSpawnArea[0], instance.game.enemyTeam.botSpawnArea[1])
            else:
                time_seen = instance.game.match.timePassed - enemy_bot.seenlast
                position = enemy_bot.position
            unknown_enemies.append([enemy_bot, position, time_seen])
    return unknown_enemies
示例#5
0
def account_for_spawns(instance, at_large_enemies):
    #Updates positions of enemies whose health is ostensibly 0 based on if they have respawned.
    #Dead enemies that have respawned still appear as health 0, and are very much a threat!
    for enemy_info in at_large_enemies:
        if enemy_info[0].health == 0 or None:
            #See if bot has respawned since it was killed.
            respawned_time = get_respawn(instance, enemy_info[0])
            #If the bot respawned figure count its last seen as the center of its respawn.
            if respawned_time != None:
                enemy_spawn_coord = Vector2.midPoint(
                    instance.game.enemyTeam.botSpawnArea[0],
                    instance.game.enemyTeam.botSpawnArea[1])
                enemy_info[1] = enemy_spawn_coord
                enemy_info[
                    2] = instance.game.match.timePassed - respawned_time + .5
            #If the bot is respawning in the next two seconds, count its last seen as the center of its respawn.
            elif instance.game.match.timeToNextRespawn < 2.00:
                enemy_spawn_coord = Vector2.midPoint(
                    instance.game.enemyTeam.botSpawnArea[0],
                    instance.game.enemyTeam.botSpawnArea[1])
                enemy_info[1] = enemy_spawn_coord
                enemy_info[2] = 2.0
            #If the game has just begun and the bot is chilling in his spawn, assign him as there. #TODO better spawn positioning.
            elif enemy_info[0].state == 0:
                enemy_spawn_coord = Vector2.midPoint(
                    instance.game.enemyTeam.botSpawnArea[0],
                    instance.game.enemyTeam.botSpawnArea[1])
                enemy_info[1] = enemy_spawn_coord
                enemy_info[
                    2] = -1.5  #This is a hack so that we evaluate enemy bots as present at the start. It works pretty well.
            #If none of the above are true, the bot is dead and we don't need to worry about him.
            else:
                at_large_enemies.remove(enemy_info)


##    print at_large_enemies
    return at_large_enemies
示例#6
0
def get_at_large_enemies(instance, known_enemies):
    #List enemies without 100% certainty of location.
    #Format is bot, last known position.
    unknown_enemies = []
    for enemy_bot in instance.game.enemyTeam.members:
        if enemy_bot not in known_enemies and enemy_bot not in unknown_enemies:
            if enemy_bot.seenlast == None:
                time_seen = 0.0
                position = Vector2.midPoint(
                    instance.game.enemyTeam.botSpawnArea[0],
                    instance.game.enemyTeam.botSpawnArea[1])
            else:
                time_seen = instance.game.match.timePassed - enemy_bot.seenlast
                position = enemy_bot.position
            unknown_enemies.append([enemy_bot, position, time_seen])
    return unknown_enemies