Esempio n. 1
0
    def assign_outskirts(self, ants):
      array = copy.deepcopy(self.level_array)	
      outskirts = self.set_outskirts(ants)
      #l.log("Outskirts: ", outskirts)
      outskirt_guide = a_star.place_all_numbers(outskirts, array)
      a = []
      for ant in self.ant_lookup:
	if self.ant_lookup[ant] == None:
	  self.ant_lookup[ant] = [outskirt_guide]
	  a.append(ant)
Esempio n. 2
0
    def assign_food(self, ants):
      array = copy.deepcopy(self.level_array)
      food_guide = a_star.place_all_numbers(self.food, array)
      rankings = self.rank_ants_proximity(food_guide)
      closest = rankings[0 : len(self.food)]
      a = []
      for ant in closest:
	if self.ant_lookup[ant] == None:
	  self.ant_lookup[ant] = [food_guide]
	  a.append(ant)
Esempio n. 3
0
    def assign_outskirts(self, ants):
      "Assign all regions that have not been seen as destination"
      array = copy.deepcopy(self.level_array)	
      outskirts = self.get_outskirts(ants)
      outskirt_guide = a_star.place_all_numbers(outskirts, array)
      a = []
      for ant in self.ant_lookup:
	if self.ant_lookup[ant] == None:
	  self.ant_lookup[ant] = outskirt_guide
	  a.append(ant)
Esempio n. 4
0
    def assign_attack(self, ants):
      array = copy.deepcopy(self.level_array)
      enemies = ants.enemy_ants_locs()
      attack_guide = a_star.place_all_numbers(enemies, array)
      rankings = self.rank_ants_proximity(attack_guide)
      closest = rankings[0 : 2]
      a = []
      for ant in closest:
	if self.ant_lookup[ant] == None:
	  self.ant_lookup[ant] = [attack_guide]
	  a.append(ant)
Esempio n. 5
0
    def assign_hills(self, ants):
      self.set_hills(ants)
      if len(self.enemy_hills) > 0: 
	array = copy.deepcopy(self.level_array)
	attack_guide = a_star.place_all_numbers(self.enemy_hills, array)
	rankings = self.rank_ants_proximity(attack_guide)
	closest = rankings[0 : self.num_ants_without_assignment() / 2]
	a = []
	for ant in closest:
	  if self.ant_lookup[ant] == None:
	    self.ant_lookup[ant] = [attack_guide]
	    a.append(ant)
Esempio n. 6
0
    def assign_defense(self, ants):
      array = copy.deepcopy(self.level_array)
      regions = self.get_defense_region(ants)	
      for hill in ants.my_hills():
	y, x = hill
	array[y][x] = -1
      defense_guide = a_star.place_all_numbers(regions, array)
      rankings = self.rank_ants_proximity(defense_guide)
      closest = rankings[0 : len(regions)]
      a = []
      for ant in closest:
	if self.ant_lookup[ant] == None:
	  self.ant_lookup[ant] = [defense_guide]
	  a.append(ant)
Esempio n. 7
0
    def assign_hills(self, ants):
      "Assign enemy hills to attack Enemy Hills"
      if len(self.enemy_hills) > 0: 
	array = copy.deepcopy(self.level_array)
	attack_guide = a_star.place_all_numbers(self.enemy_hills, array)
	rankings = self.rank_ants_proximity(attack_guide)
	ant_number = self.num_ants_without_assignment() / 2
	a = []
	for ant in rankings:
	  if self.ant_lookup[ant] == None:
	    self.ant_lookup[ant] = attack_guide
	    a.append(ant)
	  if len(a) >= ant_number:
	    break
Esempio n. 8
0
    def assign_food(self, ants):
      "Assign all food locations as destination"
      if len(self.food) > 0:
	array = copy.deepcopy(self.level_array)
	food_guide = a_star.place_all_numbers(self.food, array)
	rankings = self.rank_ants_proximity(food_guide)
	ant_number = len(self.food)
	a = []
	for ant in rankings:
	  if self.ant_lookup[ant] == None:
	    self.ant_lookup[ant] = food_guide
	    a.append(ant)
	  if len(a) >= ant_number:
	    break