def get_p_actions(self, bot): #TODO, random map filter, generate new points about best N commands, pick best from secondary filter. command_list = [] #Enemy Flag 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 = self.get_view_command(commands.Attack(bot.name, waypoints, lookAt = direction, description = "Attacking the flag at %s." % str(waypoints[-1]))) command_list.append(command) #Score location destination = self.game.team.flagScoreLocation waypoints = regressions2.get_path(self, bot.position, destination) waypoints = self.prune_waypoints(waypoints) command = self.get_view_command(commands.Charge(bot.name, waypoints, description = "Attacking our flag score point at %s." % str(waypoints[-1]))) command_list.append(command) #Update graph before calculating all new paths. for x in range(4): #Add random attack destinations direction = self.level.findRandomFreePositionInBox(self.level.area) destination = self.level.findRandomFreePositionInBox(self.level.area) waypoints = regressions2.get_path(self, bot.position, destination) #Shorten waypoint list to speed up calculations by factor of 3. waypoints = self.prune_waypoints(waypoints) command = self.get_view_command(commands.Attack(bot.name, waypoints, lookAt = direction, description = "Attacking toward the enemy.")) command_list.append(command) destination = self.level.findRandomFreePositionInBox(self.level.area) 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.")) return command_list
def get_p_actions( self, bot ): # TODO, random map filter, generate new points about best N commands, pick best from secondary filter. command_list = [] # Enemy Flag destination = self.game.enemyFlags[0].position waypoints = regressions2.get_path(self, bot.position, destination) direction = self.level.findRandomFreePositionInBox(self.level.area) command_list.append( commands.Attack(bot.name, waypoints, lookAt=direction, description="Attacking selected point.") ) # Score location destination = self.game.team.flagScoreLocation waypoints = regressions2.get_path(self, bot.position, destination) direction = self.level.findRandomFreePositionInBox(self.level.area) command_list.append( commands.Attack(bot.name, waypoints, lookAt=direction, description="Attacking selected point.") ) # Update graph before calculating all new paths. for x in range(15): # Add random attack destinations destination = self.level.findRandomFreePositionInBox(self.level.area) waypoints = regressions2.get_path(self, bot.position, destination) direction = self.level.findRandomFreePositionInBox(self.level.area) command_list.append( commands.Attack(bot.name, waypoints, lookAt=direction, description="Attacking selected point.") ) return command_list
def get_p_actions( self, bot ): #TODO, random map filter, generate new points about best N commands, pick best from secondary filter. command_list = [] #Enemy Flag 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 = self.get_view_command( commands.Attack(bot.name, waypoints, lookAt=direction, description="Attacking the flag at %s." % str(waypoints[-1]))) command_list.append(command) #Score location destination = self.game.team.flagScoreLocation waypoints = regressions2.get_path(self, bot.position, destination) waypoints = self.prune_waypoints(waypoints) command = self.get_view_command( commands.Charge( bot.name, waypoints, description="Attacking our flag score point at %s." % str(waypoints[-1]))) command_list.append(command) #Update graph before calculating all new paths. for x in range(4): #Add random attack destinations direction = self.level.findRandomFreePositionInBox(self.level.area) destination = self.level.findRandomFreePositionInBox( self.level.area) waypoints = regressions2.get_path(self, bot.position, destination) #Shorten waypoint list to speed up calculations by factor of 3. waypoints = self.prune_waypoints(waypoints) command = self.get_view_command( commands.Attack(bot.name, waypoints, lookAt=direction, description="Attacking toward the enemy.")) command_list.append(command) destination = self.level.findRandomFreePositionInBox( self.level.area) 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.")) return command_list
def get_p_actions( self, bot ): #TODO, random map filter, generate new points about best N commands, pick best from secondary filter. command_list = [] #Enemy Flag destination = self.game.enemyFlags[0].position waypoints = regressions2.get_path(self, bot.position, destination) direction = self.level.findRandomFreePositionInBox(self.level.area) command_list.append( commands.Attack(bot.name, waypoints, lookAt=direction, description="Attacking selected point.")) #Score location destination = self.game.team.flagScoreLocation waypoints = regressions2.get_path(self, bot.position, destination) direction = self.level.findRandomFreePositionInBox(self.level.area) command_list.append( commands.Attack(bot.name, waypoints, lookAt=direction, description="Attacking selected point.")) #Update graph before calculating all new paths. for x in range(15): #Add random attack destinations destination = self.level.findRandomFreePositionInBox( self.level.area) waypoints = regressions2.get_path(self, bot.position, destination) direction = self.level.findRandomFreePositionInBox(self.level.area) command_list.append( commands.Attack(bot.name, waypoints, lookAt=direction, description="Attacking selected point.")) return command_list
def build_command(self, bot, target, mode): waypoints = regressions2.get_path(self, bot.position, target) waypoints = self.prune_waypoints(waypoints) command = mode(bot.name, waypoints) return command
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
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