Beispiel #1
0
    def display(cls, agent, agent_surface, sim_surface=None):
        """
            Display an agent visualization on a pygame surface.

        :param agent: the agent to be displayed
        :param agent_surface: the pygame surface on which the agent is displayed
        :param sim_surface: the pygame surface on which the environment is displayed
        """

        if isinstance(agent, AbstractDQNAgent):
            DQNGraphics.display(agent, agent_surface, sim_surface)
        elif isinstance(agent, BFTQAgent):
            BFTQGraphics.display(agent, agent_surface)
        elif isinstance(agent, ValueIterationAgent):
            ValueIterationGraphics.display(agent, agent_surface)
        elif isinstance(agent, MCTSAgent):
            MCTSGraphics.display(agent, agent_surface)
        elif isinstance(agent, IntervalRobustPlannerAgent):
            IntervalRobustPlannerGraphics.display(agent, agent_surface, sim_surface)
        elif isinstance(agent, DiscreteRobustPlannerAgent):
            DiscreteRobustPlannerGraphics.display(agent, agent_surface, sim_surface)
        elif isinstance(agent, ConstrainedEPCAgent):
            ConstrainedEPCGraphics.display(agent, agent_surface, sim_surface)
        elif isinstance(agent, RobustEPCAgent):
            RobustEPCGraphics.display(agent, agent_surface, sim_surface)
        elif isinstance(agent, AbstractTreeSearchAgent):
            TreeGraphics.display(agent, agent_surface)
 def display(cls, agent, agent_surface, sim_surface):
     plan = agent.planner.get_plan()
     for env in [preprocess_env(agent.true_env, preprocessors) for preprocessors in agent.config["models"]]:
         IntervalRobustPlannerGraphics.display_uncertainty(env, plan, sim_surface, trajectory=False)
         # for vehicle in env.road.vehicles:
         #     if hasattr(vehicle, ):
         #         IntervalRobustPlannerGraphics.display(vehicle)
         # for vehicle in env.road.vehicles:
         #     vehicle.trajectory = []
         # for action in plan[:horizon] + (horizon - len(plan)) * [1]:
         #     env.step(action)
         # for vehicle in env.road.vehicles:
         #     if vehicle is env.vehicle:
         #         continue
         #     uncertainty_surface = pygame.Surface(sim_surface.get_size(), pygame.SRCALPHA, 32)
         #     IntervalRobustPlannerGraphics.display_trajectory(vehicle.trajectory, uncertainty_surface, sim_surface,
         #                                                      IntervalRobustPlannerGraphics.MODEL_TRAJ_COLOR)
         #     sim_surface.blit(uncertainty_surface, (0, 0))
     TreeGraphics.display(agent, agent_surface)
Beispiel #3
0
    def display(cls, agent, agent_surface, sim_surface=None):
        """
            Display an agent visualization on a pygame surface.

        :param agent: the agent to be displayed
        :param agent_surface: the pygame surface on which the agent is displayed
        :param sim_surface: the pygame surface on which the environment is displayed
        """

        if isinstance(agent, AbstractDQNAgent):
            DQNGraphics.display(agent, agent_surface)
        elif isinstance(agent, ValueIterationAgent):
            ValueIterationGraphics.display(agent, agent_surface)
        elif isinstance(agent, MCTSAgent):
            MCTSGraphics.display(agent, agent_surface)
        elif isinstance(agent, IntervalRobustPlannerAgent):
            IntervalRobustPlannerGraphics.display(agent, agent_surface,
                                                  sim_surface)
        elif isinstance(agent, DiscreteRobustPlannerAgent):
            DiscreteRobustPlannerGraphics.display(agent, agent_surface,
                                                  sim_surface)
        elif isinstance(agent, DeterministicPlannerAgent) \
                or isinstance(agent, OLOPAgent):
            TreeGraphics.display(agent, agent_surface)
 def display(cls, agent, agent_surface, sim_surface):
     robust_env = preprocess_env(agent.env, agent.config["env_preprocessors"])
     cls.display_uncertainty(robust_env, plan=agent.get_plan(), surface=sim_surface)
     if agent_surface and hasattr(agent, "sub_agent"):
         TreeGraphics.display(agent.sub_agent, agent_surface)