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)}')
예제 #2
0
 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)
예제 #3
0
 def route_with_purpose(self, location, purpose):
     self._route_to(CityMap.route(self.location, location))
     self.re_purpose(purpose)