def position_is_free(self, position): if distance_from_points(position, self._host.get_position()) > self._feel_distance: raise Exception("Can't feel so far") return self._grid.is_free(position)
def _order_by_far_away(self, positions): last_walked_pos = self.get_last_memory_since_blocked()[1] return sorted(positions, key=lambda pos: distance_from_points(last_walked_pos, pos), reverse=True)