def get_new_runner(self,
                       mp: 'Map',
                       algorithm_type: Type['Algorithm'],
                       algorithm_parameters: Tuple[List, Dict] = None,
                       algorithm_testing: Optional[
                           Type['BasicTesting']] = None,
                       with_animations: bool = False) -> 'AlgorithmRunner':
        if not algorithm_parameters:
            algorithm_parameters = [], {}

        from simulator.services.services import Services
        config = Configuration()
        config.simulator_initial_map = mp
        config.simulator_algorithm_type = algorithm_type
        config.simulator_testing_type = algorithm_testing
        config.simulator_algorithm_parameters = algorithm_parameters

        if with_animations and algorithm_testing:
            config.simulator_graphics = True
            config.simulator_key_frame_speed = self._services.settings.simulator_key_frame_speed
            config.simulator_key_frame_skip = self._services.settings.simulator_key_frame_skip

        s = Services(config)

        if with_animations and algorithm_testing:
            s.algorithm.__pass_root_key_frame = self.__pass_root_key_frame

        return s.algorithm
Example #2
0
    def __run_simulation(self,
                         grid: Map,
                         algorithm_type: Type[Algorithm],
                         testing_type: Type[BasicTesting],
                         algo_params: Tuple[list, dict],
                         agent_pos: Point = None) -> Dict[str, Any]:
        config = Configuration()
        config.simulator_initial_map = copy.deepcopy(grid)
        config.simulator_algorithm_type = algorithm_type
        config.simulator_testing_type = testing_type
        config.simulator_algorithm_parameters = algo_params

        if agent_pos:
            config.simulator_initial_map.move_agent(agent_pos, True, False)

        sim: Simulator = Simulator(Services(config))
        return sim.start().get_results()