def initialize(self): """Use this function to setup your bot before the game starts.""" #Initialized a graphical representation of work and the graph. #Makes 88x50 graph with adjacent squares having edges. #CALLS regressions2.makeGraph to do this. regressions2.initialize_graphics(self) regressions2.update_graph(self) #@test #Calculate initial probability distribution for location of enemies. enemy_belief.update_enemy_graph(self) self.verbose = True self.counter = 0 #Used to store bots current command. self.bots = {} for bot in self.game.team.members: self.bots[bot.name] = {} self.bots[bot.name]["command"] = None # Classifier: Structured as {commands.Attack : (regression0, coefficient0), (regression1, coefficient1}... commands.Defend : (regression0.....)} self.classifier = self.classifierGenerator() ## self.issue_initial() print 'DONE initializing'
def initialize(self): """Use this function to setup your bot before the game starts.""" # Initialized a graphical representation of work and the graph. # Makes 88x50 graph with adjacent squares having edges. # CALLS regressions2.makeGraph to do this. regressions2.initialize_graphics(self) regressions2.update_graph(self) # @test # Calculate initial probability distribution for location of enemies. enemy_belief.update_enemy_graph(self) self.verbose = True self.counter = 0 # Used to store bots current command. self.bots = {} for bot in self.game.team.members: self.bots[bot.name] = {} self.bots[bot.name]["command"] = None # Classifier: Structured as {commands.Attack : (regression0, coefficient0), (regression1, coefficient1}... commands.Defend : (regression0.....)} self.classifier = self.classifierGenerator() ## self.issue_initial() print "DONE initializing"
def update_score_graph(instance): reset_graph(instance) #Updates node information about enemy position, sight, fire enemy_belief.update_enemy_graph(instance) #Updates graph edges to account for new node information update_fire_graph(instance, importance = 70.0) update_sight_graph(instance, importance = 0.0) update_position_graph(instance, importance = 15.0)
def update_graph(instance): reset_graph(instance) #Updates node information about enemy position, sight, fire enemy_belief.update_enemy_graph(instance) #Updates graph edges to account for new node information update_fire_graph(instance, importance = 50) update_sight_graph(instance, importance = 1) update_position_graph(instance, importance = -2.0) update_pheremone_graph(instance, importance = 10) spawn_camp.update_choke_redundancy(instance)
def tick(self): """Routine to deal with new information every interval of about .1s""" self.counter += 1 # Refreshes visuals if self.counter % 15 == 0: ## regressions2.update_graphics(self) enemy_belief.update_enemy_graph(self) self.visualizer.tick() # Updates graph info regressions2.update_graph(self) test_enemy = self.game.enemyTeam.members[0] if self.counter % 20 == 0: pass ## print "health: " , test_enemy.health ## print "state: ", test_enemy.state ## print "position: ", test_enemy.position ## print "facingDirection: ", test_enemy.facingDirection for bot in self.game.team.members: # If it makes sense to move, evaluate actions and take the best. Otherwise don't waste processing power calculating an action. can_shoot_enemy, no_enemy_sighted = self.check_to_see_if_no_command(bot) if ( self.counter % 15 == 0 and can_shoot_enemy == False and bot.health > 0 or bot in self.game.bots_available ): legalActions = self.get_p_actions(bot) command, value = self.get_action(bot, legalActions) # Consider whether the strength of continuing the current command and hence having no command wait is superior. # If it isn't, issue the command, otherwise, continue the present command. # Resets bots' stored commands to None who are dead or have finished a task. self.refresh_bot_commands() if self.bots[bot.name]["command"] != None: continue_value = regressions2.evaluate_continue_present_command(self, bot, command) if continue_value > value: # TODO calibrate skipping continue self.issueCMD(command)
def tick(self): """Routine to deal with new information every interval of about .1s""" self.counter += 1 #Refreshes visuals if self.counter % 15 == 0: ## regressions2.update_graphics(self) enemy_belief.update_enemy_graph(self) self.visualizer.tick() #Updates graph info regressions2.update_graph(self) test_enemy = self.game.enemyTeam.members[0] if self.counter % 20 == 0: pass ## print "health: " , test_enemy.health ## print "state: ", test_enemy.state ## print "position: ", test_enemy.position ## print "facingDirection: ", test_enemy.facingDirection for bot in self.game.team.members: #If it makes sense to move, evaluate actions and take the best. Otherwise don't waste processing power calculating an action. can_shoot_enemy, no_enemy_sighted = self.check_to_see_if_no_command( bot) if self.counter % 15 == 0 and can_shoot_enemy == False and bot.health > 0 or bot in self.game.bots_available: legalActions = self.get_p_actions(bot) command, value = self.get_action(bot, legalActions) #Consider whether the strength of continuing the current command and hence having no command wait is superior. #If it isn't, issue the command, otherwise, continue the present command. #Resets bots' stored commands to None who are dead or have finished a task. self.refresh_bot_commands() if self.bots[bot.name]["command"] != None: continue_value = regressions2.evaluate_continue_present_command( self, bot, command) if continue_value > value: #TODO calibrate skipping continue self.issueCMD(command)