Exemple #1
0
def move(grid, ant, side, pheromone):
    radius = ant.get_radius()
    location = ant.get_location()
    symbol = ant.get_symbol()
    old_location = grid[location] 
    grid[location] = (old_location[0], EMPTY, old_location[2])    
    new_location = radius[2*side + 1]
    ant.set_location(new_location)        
    set_orientation(ant,side)
    if pheromone == EMPTY:
        grid[new_location] = (grid[new_location][0], ANT, grid[new_location][2])
    else:
        grid[new_location] = (pheromone, ANT, symbol)
Exemple #2
0
 def is_pheromone_in_radius(self, ant):
     radius = ant.get_radius()
     for i in [1,3,5,7]:
         if (self[radius[i]][2] != ant.get_symbol()) and (self[radius[i]][2] != EMPTY) and (self[radius[i]][2] != OBSTACLE):
             return [radius[i],i]
     return 0
Exemple #3
0
 def place_ant_on_grid(self, ant, location):
     ant_i = int(ant.get_symbol()) - 1
     self[(location)] = (START, ANT, ant.get_symbol())
     self.ant_locations[ant_i] = location
     self.ant_homes[ant_i] = location
     self.ants[ant_i] = ant