Esempio n. 1
0
 def _simulate_task_meta(self, task, user_input, dilate=True):
     if self._config['mode'] == DEV_MODE:
         util.save_user_input(user_input, LAST_INPUT_PATH)
     if self._config['mode'] == DEMO_MODE:
         user_input.flattened_point_list = []
         user_input.polygons = []
         if user_input.balls:
             user_input.balls = user_input.balls[:self._config['max_balls']]
     task.scene = simulator.add_user_input_to_scene(
         task.scene, user_input, keep_space_around_bodies=dilate)
     print('Converted %d points, %d polygons, %d balls into %d bodies'
           ' with %d shapes' %
           (len(user_input.flattened_point_list or []) / 2,
            len(user_input.polygons or []), len(
                user_input.balls or []), len(task.scene.user_input_bodies),
            sum(len(b.shapes) for b in task.scene.user_input_bodies)))
     simulation = simulator.simulate_task(task, stride=3)
     if self._config['mode'] == DEV_MODE:
         rendered = [
             get_scene_as_base64_image(scene)
             for scene in simulation.sceneList[::10]
         ]
     else:
         rendered = []
     return task_if.TaskSimulationWithMeta(simulation=simulation,
                                           rendered_imgs=rendered)
Esempio n. 2
0
 def save_solution(self, task_id, user_input):
     assert self._config['mode'] != DEMO_MODE
     util.save_user_input(user_input, util.get_solution_path(task_id))