def can_interact(a1, a2) -> bool:
     """\
 :type a1: ModularAnt
 :type a2: ModularAnt
     """
     SIMILARITY_THRESHOLD: float = 1
     return (-1 * SIMILARITY_THRESHOLD <= Direction.dif_mag(a1.get_facing(),
         a2.get_facing().reversed()) <= SIMILARITY_THRESHOLD)
 def pheromone_bias(world: World, position: Position, direction: Direction,
                    weight: float) -> float:
     try:
         loc: Location = world.get_location(position.x + direction.get()[0],
                                            position.y + direction.get()[1])
         return weight + (bias * loc.get_pheromone_count()
                          if loc.is_free() and weight != 0 else 0)
     except IndexError:
         return 0
 def exploration_bias(world: World, position: Position,
                      direction: Direction, weight: float) -> float:
     try:
         loc: Location = world.get_location(position.x + direction.get()[0],
                                            position.y + direction.get()[1])
         return weight * (tanh((age - 130) / 10) + 2 # weight * 5 * (tanh((age - 130)/(10)) + 1.2 #
                                     ) if (loc.get_pheromone_count() <= FORAGING_PHEROMONE_THRESHOLD and
                                     loc.get_brood_pheromone_count() <= FORAGING_PHEROMONE_THRESHOLD) or \
                                     loc.get_foraging_pheromone_count() > FORAGING_PHEROMONE_THRESHOLD else weight
     except IndexError:
         return 0
 def __init__(self,
              pheromone_bias: float = 0,
              hold_chance: float = DEFAULT_VARIATION_CHANCE,
              wobble_chance: float = DEFAULT_WOBBLE_CHANCE):
     self.pheromone_bias: float = pheromone_bias
     self.hold_chance: float = hold_chance
     self.wobble_chance: float = wobble_chance
     self.facing: Direction = Direction(random.choice(array([-1, 0, -1])),
                                        random.choice(array([-1, 0, -1])))
     self.age: float = 0
     self.seeking_food: bool = False
 def brood_direction(_: World, pos: Position, direction: Direction, weight: float) -> float:
     return Direction.similarity_score(Direction(brood_pos[0] - pos.x, brood_pos[1] - pos.y), direction) * \
            holdness * weight
 def hold_direction(_: World, __: Position, direction: Direction,
                    weight: float) -> float:
     return Direction.similarity_score(prev_dir,
                                       direction) * holdness * weight