Exemple #1
0
 def graphics_tick(self):
     if self.GRAPHICS:
         regressions2.update_graphics_probability(self, mode=self.GRAPHICS)
         self.visualizer.tick()
     elif self.DRAW_POINTS:
         regressions2.draw_points(self, self.points)
         self.visualizer.tick()
         self.visibilities.fill(0)
Exemple #2
0
 def graphics_tick(self):
     if self.GRAPHICS:
         regressions2.update_graphics_probability(self, mode = self.GRAPHICS) 
         self.visualizer.tick()
     elif self.DRAW_POINTS:
         regressions2.draw_points(self, self.points)
         self.visualizer.tick()
         self.visibilities.fill(0)
Exemple #3
0
    def get_p_actions(
        self, bot
    ):  #TODO, random map filter, generate new points about best N commands, pick best from secondary filter.
        command_list = []

        #If our bot has the flag... don't run toward the enemy, go score!
        if bot.flag:
            #Score location
            destination = self.game.team.flagScoreLocation
            regressions2.update_score_graph(self)
            waypoints = regressions2.get_path(self, bot.position, destination)
            waypoints = self.prune_waypoints(waypoints)
            command_list.append(
                commands.Move(bot.name,
                              waypoints,
                              description="Moving toward the flag score."))
            regressions2.update_graph(self)
            return command_list

        #Random
        target = self.level.findRandomFreePositionInBox(self.level.area)
        waypoints = regressions2.get_path(self, bot.position, target)
        command_list.append(
            commands.Attack(bot.name,
                            waypoints,
                            description="Attacking to random position"))

        potential_flanking_positions = self.get_flanking_positions(bot,
                                                                   actions=6)
        potential_charge_flank = potential_flanking_positions[
            len(potential_flanking_positions) / 2:-1]

        if self.DRAW_POINTS == "flanking":
            regressions2.draw_points(self, potential_flanking_positions)

        #Defend
        redundancy = 0
        friendlies = regressions2.get_friendlies_in_range(
            self, bot.position, 2)
        campers = 0
        for friendly in friendlies:
            if friendly.state == 2:
                redundancy += 1
        if redundancy < 3 and len(friendlies) <= 3:
            defend_command = commands.Defend(bot.name)
            command_list.append(defend_command)

        living_enemies = 0
        for enemy in self.game.enemyTeam.members:
            if enemy.health > 0:
                living_enemies += 1
        if len(self.game.bots_alive) / (living_enemies + 1) > 1.3 or (
                bot.position -
                self.game.enemyTeam.flag.position).length() < 30:
            #Enemy Flag - ATTACK AND CHARGE
            destination = self.game.enemyTeam.flag.position
            direction = self.level.findRandomFreePositionInBox(self.level.area)
            waypoints = regressions2.get_path(self, bot.position, destination)
            waypoints = self.prune_waypoints(waypoints)
            command_list.append(
                commands.Attack(bot.name,
                                waypoints,
                                description="Attacking toward enemy flag."))
        if len(self.game.bots_alive) / (living_enemies + 1) > 1.5 or (
                bot.position -
                self.game.enemyTeam.flag.position).length() < 25:
            command_list.append(
                commands.Charge(bot.name,
                                waypoints,
                                description="Charging toward the enemy flag."))

        for position in potential_flanking_positions:
            destination = position
            waypoints = regressions2.get_path(self, bot.position, destination)
            #Shorten waypoint list to speed up calculations.
            waypoints = self.prune_waypoints(waypoints)
            command_list.append(
                commands.Attack(
                    bot.name,
                    waypoints,
                    description="Flanking toward the enemy at %s." %
                    waypoints[-1]))

        for position in potential_charge_flank:
            destination = position
            waypoints = regressions2.get_path(self, bot.position, destination)
            waypoints = self.prune_waypoints(waypoints)
            command_list.append(
                commands.Charge(
                    bot.name,
                    waypoints,
                    description="Charging toward the enemy at %s." %
                    waypoints[-1]))

        if bot.position.distance(
                self.level.botSpawnAreas[self.game.enemyTeam.name][0]) < 15:
            potential_camp_positions = self.get_potential_camp_positions(
                bot, actions=10)
            for destination in potential_camp_positions:
                skip_tail = False
                for bot_name in self.bots.keys():  #TODO fix based on distance.
                    #No duplicate destinations.
                    command = self.bots[bot_name]["command"]
                    if command != None:
                        friendly = self.get_bot_from_command(command)
                        if friendly == bot:
                            skip_tail = True
                            break
                        if type(
                                command
                        ) == commands.Defend and friendly.position.distance(
                                destination) < 1.0:
                            skip_tail = True
                            break
                        if type(command) != commands.Defend:
                            if self.bots[bot_name]["command"].target[
                                    -1].distance(destination) < 1.0:
                                skil_tail = True
                                break
                if not skip_tail:
                    command = self.build_command(bot, destination,
                                                 commands.Attack)
                    command_list.append(command)
                    command = self.build_command(bot, destination,
                                                 commands.Charge)
                    command_list.append(command)

        return command_list
Exemple #4
0
    def get_p_actions(self, bot): #TODO, random map filter, generate new points about best N commands, pick best from secondary filter.
        command_list = []

        #If our bot has the flag... don't run toward the enemy, go score!
        if bot.flag:
            #Score location
            destination = self.game.team.flagScoreLocation
            regressions2.update_score_graph(self)
            waypoints = regressions2.get_path(self, bot.position, destination)
            waypoints = self.prune_waypoints(waypoints)
            command_list.append(commands.Move(bot.name, waypoints, description = "Moving toward the flag score."))
            regressions2.update_graph(self)
            return command_list      

        #Random
        target = self.level.findRandomFreePositionInBox(self.level.area)
        waypoints = regressions2.get_path(self, bot.position, target)
        command_list.append(commands.Attack(bot.name, waypoints, description = "Attacking to random position"))
        
        potential_flanking_positions = self.get_flanking_positions(bot, actions = 6)
        potential_charge_flank = potential_flanking_positions[len(potential_flanking_positions)/2:-1]
        
        if self.DRAW_POINTS == "flanking":
            regressions2.draw_points(self, potential_flanking_positions) 

        #Defend
        redundancy = 0
        friendlies = regressions2.get_friendlies_in_range(self, bot.position, 2)
        campers = 0
        for friendly in friendlies:
            if friendly.state == 2:
                redundancy += 1
        if redundancy < 3 and len(friendlies) <= 3:  
            defend_command = commands.Defend(bot.name)
            command_list.append(defend_command)

        living_enemies = 0
        for enemy in self.game.enemyTeam.members:
            if enemy.health > 0:
                living_enemies += 1
        if len(self.game.bots_alive)/(living_enemies+1) > 1.3 or (bot.position - self.game.enemyTeam.flag.position).length() < 30:
            #Enemy Flag - ATTACK AND CHARGE
            destination = self.game.enemyTeam.flag.position
            direction = self.level.findRandomFreePositionInBox(self.level.area)
            waypoints = regressions2.get_path(self, bot.position, destination)
            waypoints = self.prune_waypoints(waypoints)
            command_list.append(commands.Attack(bot.name, waypoints, description = "Attacking toward enemy flag."))            
        if len(self.game.bots_alive)/(living_enemies+1) > 1.5 or (bot.position - self.game.enemyTeam.flag.position).length() < 25:
            command_list.append(commands.Charge(bot.name, waypoints, description = "Charging toward the enemy flag."))


        for position in potential_flanking_positions:
            destination = position
            waypoints = regressions2.get_path(self, bot.position, destination)
            #Shorten waypoint list to speed up calculations.
            waypoints = self.prune_waypoints(waypoints)
            command_list.append(commands.Attack(bot.name, waypoints, description = "Flanking toward the enemy at %s." % waypoints[-1]))
            
        for position in potential_charge_flank:
            destination = position
            waypoints = regressions2.get_path(self, bot.position, destination)
            waypoints = self.prune_waypoints(waypoints)
            command_list.append(commands.Charge(bot.name, waypoints, description = "Charging toward the enemy at %s." % waypoints[-1]))

        if bot.position.distance(self.level.botSpawnAreas[self.game.enemyTeam.name][0]) < 15:
            potential_camp_positions = self.get_potential_camp_positions(bot, actions = 10)
            for destination in potential_camp_positions:
                skip_tail = False
                for bot_name in self.bots.keys(): #TODO fix based on distance.
                    #No duplicate destinations.
                    command = self.bots[bot_name]["command"]
                    if command != None:
                        friendly = self.get_bot_from_command(command)
                        if friendly == bot:
                            skip_tail = True
                            break
                        if type(command) == commands.Defend and friendly.position.distance(destination) < 1.0:
                            skip_tail = True
                            break
                        if type(command) != commands.Defend:
                            if self.bots[bot_name]["command"].target[-1].distance(destination) < 1.0:
                                skil_tail = True
                                break     
                if not skip_tail:
                    command = self.build_command(bot, destination, commands.Attack)
                    command_list.append(command)
                    command = self.build_command(bot, destination, commands.Charge)
                    command_list.append(command)

        return command_list