Exemple #1
0
 def gen_combat_safety(self, ants):
     all_ants = list(ants.ant_set)
     player_ants = []
     for owner in xrange(10):
         player_ants.append([a for a in all_ants if a.contents == owner])
     
     combat_stamp = self.approx_combat_stamp
     attack_field = self.attack_field
     weakness_field = self.weakness_field
     safety_field = self.safety_field
     attack_field.fill(0)
     weakness_field.fill(0)
     safety_field.fill(0)
     
     for owner in xrange(10):
         player_attack = attack_field[owner]
         for ant in player_ants[owner]:
             increment_stamp(player_attack, combat_stamp, ant)
Exemple #2
0
 def gen_combat_safety(self, ants):
     player_ants = []
     positions = []
     for owner in xrange(10):
         player_ants.append([a for a in ants.ant_set if a.contents == owner])
     
     attack_stamp = ants.attack_stamp
     combat_stamp = self.approx_combat_stamp
     attack_field = self.attack_field
     weakness_field = self.weakness_field
     best_enemy = self.lowest_enemy_weakness
     safety_field = self.safety_field
     attack_field.fill(0)
     weakness_field.fill(0)
     best_enemy.fill(INF)
     safety_field.fill(SAFE)
     
     for owner in xrange(10):
         player_attack = attack_field[owner]
         for ant in player_ants[owner]:
             increment_stamp(player_attack, combat_stamp, ant)
     for owner in xrange(10):
         weakness_field[owner] = sum(attack_field[p] 
                                 for p in xrange(10) if p != owner)
         arena = set(loc for a in player_ants[owner]
                             for loc in a.moves
                                 if weakness_field[owner][loc] > 0)
         positions.append(arena)
     for enemy in xrange(1,10):
         for enemy_position in positions[enemy]:
             min_stamp(best_enemy, 
                       (attack_stamp, weakness_field[enemy][enemy_position]),
                       enemy_position)
     my_weakness = weakness_field[ME]
     safety_field[my_weakness > best_enemy] = DIE
     safety_field[my_weakness == best_enemy] = NEUTRAL
     
     self.soldiers = set(a for a in player_ants[ME] 
                               if positions[ME].intersection(a.moves))