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)
def follow_arrow (grid, ant): radius = ant.get_radius() orientation = ant.get_orientation() location = ant.get_location() old_location = grid[location] grid[location] = (old_location[0], EMPTY, old_location[2]) if grid[location][0] == UP_SYM: # print "up" ant.set_location(radius[(9 - 2*(orientation)) % 8]) force_orientation(ant,UP) elif grid[location][0] == RIGHT_SYM: # print "right" ant.set_location(radius[(11 - 2*(orientation)) % 8]) force_orientation(ant,RIGHT) elif grid[location][0] == DOWN_SYM: # print "down" ant.set_location(radius[(13 - 2*(orientation)) % 8]) force_orientation(ant,DOWN) elif grid[location][0] == LEFT_SYM: # print "left" ant.set_location(radius[(7 - 2*(orientation)) % 8]) force_orientation(ant,LEFT) new_location = ant.get_location() # print "new location is ", new_location grid[new_location] = (grid[new_location][0], ANT, grid[new_location][2])