コード例 #1
0
 def update_explore_influence(self, explore_influence):
     if self.explore_method == 'cluster':
         debug_logger.debug('update_explore_influence == cluster') 
         self.update_explore_influence_cluster(explore_influence)
     else:
         debug_logger.debug('update_explore_influence == expansion')
         self.update_explore_influence_expansion(explore_influence)
コード例 #2
0
 def update_explore_influence(self, explore_influence):
     # my explorers
     for ant_loc in [ant for ant in self.gamestate.my_ants() 
                     if ant not in self.gamestate.my_fighters] :
         neighbour_ants = [ant for ant in self.gamestate.neighbour_table[ant_loc] if ant in self.gamestate.ant_list]
         explore_influence.map[ant_loc] +=  self.my_explorer_value * (len(neighbour_ants) + 1)
     # my fighters
     debug_logger.debug('update_explore_influence setting my fighters: %s' % str(self.gamestate.my_fighters))
     for ant_loc in self.gamestate.my_fighters:
         explore_influence.map[ant_loc] += self.my_fighter_value
コード例 #3
0
 def update_explore_influence(self, explore_influence):
     # visible tiles
     for row in range(self.gamestate.rows):
         for col in range(self.gamestate.cols):
             if self.gamestate.visible((row,col)):
                 explore_influence.map[row,col] += self.my_explorer_value
     # my fighters
     debug_logger.debug('update_explore_influence setting my fighters: %s' % str(self.gamestate.my_fighters))
     for ant_loc in self.gamestate.my_fighters:
         explore_influence.map[ant_loc] += self.my_fighter_value
コード例 #4
0
 def update_explore_influence_expansion(self, explore_influence):                    
     # my explorers
     for ant_loc in [ant for ant in self.gamestate.my_ants() 
                     if ant not in self.gamestate.my_fighters
                     and ant not in self.gamestate.my_combat_explorers] :
         neighbour_ants = [ant for ant in self.gamestate.neighbour_table[ant_loc] if ant in self.gamestate.ant_list]
         explore_influence.map[ant_loc] +=  self.my_explorer_value * (len(neighbour_ants) + 1)
     # my fighters
     debug_logger.debug('update_explore_influence setting my fighters: %s' % str(self.gamestate.my_fighters))
     for ant_loc in self.gamestate.my_fighters:
         explore_influence.map[ant_loc] += self.my_fighter_value
コード例 #5
0
 def update_explore_influence_cluster(self, explore_influence):
     # visible tiles
     for row in range(self.gamestate.rows):
         for col in range(self.gamestate.cols):
             if self.gamestate.visible((row,col)):
                 self.safe_belief[row,col] = 1
             else:
                 self.safe_belief[row,col] -= 0.1
             explore_influence.map[row,col] += self.my_explorer_value * self.safe_belief[row,col]
     # my explorers
     for ant_loc in [ant for ant in self.gamestate.my_ants() 
                     if ant not in self.gamestate.my_fighters
                     and ant not in self.gamestate.my_combat_explorers] :
         explore_influence.map[ant_loc] +=  self.my_explorer_value * 0.1
         
     # my fighters
     debug_logger.debug('update_explore_influence setting my fighters: %s' % str(self.gamestate.my_fighters))
     for ant_loc in self.gamestate.my_fighters:
         explore_influence.map[ant_loc] += self.my_fighter_value
コード例 #6
0
 def update_aggressiveness(self, influence):
     'update dynamic goal values depending on current situation'
     # assess situation
     my_tile_count = len([v for v in np.ravel(np.fabs(influence.map)) if v > 0.01])
     total_tile_count = self.gamestate.cols * self.gamestate.rows
     self.gamestate.winning_percentage = float(my_tile_count)/total_tile_count
     debug_logger.debug('currently owning %d in %d tiles, ratio: %f' % 
         (my_tile_count, total_tile_count, self.gamestate.winning_percentage))
     debug_logger.debug('my ant_hill is at %s' % str(self.gamestate.my_hills()))
     debug_logger.debug('known enemy hill: %s' % str(self.gamestate.enemy_hills()))
     
     # alter aggressiveness as situation changes
     self.my_fighter_value = 0 - 1 - (self.gamestate.winning_percentage / 0.3 % 1)
     self.enemy_ant_value = 0 - (self.gamestate.winning_percentage / 0.3 % 1) * 2
コード例 #7
0
    def update_aggressiveness(self, influence):
        "update dynamic goal values depending on current situation"
        # assess situation
        my_tile_count = len([v for v in np.ravel(influence.map) if v > CUTOFF])
        total_tile_count = self.gamestate.cols * self.gamestate.rows
        self.gamestate.winning_percentage = float(my_tile_count) / total_tile_count
        debug_logger.debug(
            "currently owning %d in %d tiles, ratio: %f"
            % (my_tile_count, total_tile_count, self.gamestate.winning_percentage)
        )
        debug_logger.debug("my ant_hill is at %s" % str(self.gamestate.my_hills()))
        debug_logger.debug("known enemy hill: %s" % str(self.gamestate.enemy_hills()))

        # alter aggressiveness as situation changes
        # self.my_fighter_value = 0 - 1 - (self.gamestate.winning_percentage / 0.3 % 1)
        # self.enemy_ant_value = 0 - (self.gamestate.winning_percentage / 0.3 % 1) * 2
        self.enemy_hill_value = -15 + -15 * int(self.gamestate.winning_percentage / 0.2)
コード例 #8
0
 def update_aggressiveness(self, influence):
     'update dynamic goal values depending on current situation'
     # assess situation
     my_tile_count = len([v for v in np.ravel(influence.map) if v > CUTOFF])
     total_tile_count = self.gamestate.cols * self.gamestate.rows
     self.gamestate.winning_percentage = float(my_tile_count)/total_tile_count
     debug_logger.debug('currently owning %d in %d tiles, ratio: %f' % 
         (my_tile_count, total_tile_count, self.gamestate.winning_percentage))
     debug_logger.debug('my ant_hill is at %s' % str(self.gamestate.my_hills()))
     debug_logger.debug('known enemy hill: %s' % str(self.gamestate.enemy_hills()))
     
     # alter aggressiveness as situation changes
     # self.my_fighter_value = 0 - 1 - (self.gamestate.winning_percentage / 0.3 % 1)
     # self.enemy_ant_value = 0 - (self.gamestate.winning_percentage / 0.3 % 1) * 2
     self.enemy_hill_value = -15 + -15 * int(self.gamestate.winning_percentage / 0.2)
     self.enemy_ant_value = -1 * int(self.gamestate.winning_percentage / 0.2)
     if self.gamestate.winning_percentage > 0.2:
         self.explore_method = 'cluster'
     else:
         self.explore_method = 'expansion'