def move_forward(self, route: List): """ Method which moves the actor towards end of the route If actor is not on an edge adjacent to beginning of the route, it routes him towards the beginning, with most optimal route :return: """ try: first_waypoint = route.pop(0) except IndexError: raise RoutingError('Cannot move forward, empty route') if CityMap.are_neighbors(first_waypoint, self.location): self.move_to(first_waypoint) else: route_to_waypoint = CityMap.route(self.location, first_waypoint) try: self.move_to(route_to_waypoint[0]) except IndexError: raise RoutingError('Cannot find route to waypoint') if hasattr(self, 'log'): self.log.info(f'Moving to {id(first_waypoint)}')
def _route_with_purpose( self, location, purpose ): # TODO: Refactor - abstract out to geolocated + purposeful actor self._route_to(CityMap.route(self.location, location)) self.re_purpose(purpose)
def route_with_purpose(self, location, purpose): self._route_to(CityMap.route(self.location, location)) self.re_purpose(purpose)