def simulate_scene( scene: scene_if.Scene, steps: int = DEFAULT_MAX_STEPS, stride: int = 1, physics: scene_if.Physics = scene_if.Physics() ) -> List[scene_if.Scene]: serialized_scenes = simulator_bindings.simulate_scene( serialize(scene), steps, stride, serialize(physics)) scenes = [deserialize(scene_if.Scene(), b) for b in serialized_scenes] return scenes
def __init__(self): # Create empty scene and task. self.scene = scene_if.Scene(bodies=[]) self.scene.width = constants.SCENE_WIDTH self.scene.height = constants.SCENE_HEIGHT self.body_list = [] # Build the bounding walls. self.bottom_wall = self._add_wall('bottom') self.left_wall = self._add_wall('left') self.top_wall = self._add_wall('top') self.right_wall = self._add_wall('right')
def __init__(self): # Create empty scene and task. self.scene = scene_if.Scene(bodies=[]) self.scene.width = constants.SCENE_WIDTH self.scene.height = constants.SCENE_HEIGHT self.task = task_if.Task(scene=self.scene, bodyId1=-1, bodyId2=-1, relationships=[self.SpatialRelationship.NONE], phantomShape=None) self.set_meta(self.SolutionTier.GENERAL) self.body_list = [] # Build the bounding walls. self.bottom_wall = self._add_wall('bottom') self.left_wall = self._add_wall('left') self.top_wall = self._add_wall('top') self.right_wall = self._add_wall('right')
def add_user_input_to_scene(scene, user_input, keep_space_around_bodies=True): """Converts user input to objects in the scene. Args: scene: scene_if.Scene. user_input: scene_if.UserInput or a triple (points, rectangulars, balls). keep_space_around_bodies: bool, if True extra empty space will be enforced around scene bodies. Returns: task_simulation: task_if.TaskSimulation. """ if not isinstance(user_input, scene_if.UserInput): user_input = build_user_input(*user_input) return deserialize( scene_if.Scene(), simulator_bindings.add_user_input_to_scene(serialize(scene), serialize(user_input), keep_space_around_bodies))
def simulate_scene(scene, steps=DEFAULT_MAX_STEPS): serialized_scenes = simulator_bindings.simulate_scene( serialize(scene), steps) scenes = [deserialize(scene_if.Scene(), b) for b in serialized_scenes] return scenes