def reset(self): """Implements dm_env.Environment.reset.""" response = self._connection.send(dm_env_rpc_pb2.ResetRequest()) if self._dm_env_rpc_specs != response.specs: raise RuntimeError('Environment changed spec after reset') self._last_state = dm_env_rpc_pb2.EnvironmentStateType.INTERRUPTED return self.step({})
def test_reset_seed_setting(self): self._world_name = self._connection.send( dm_env_rpc_pb2.CreateWorldRequest( settings={'seed': tensor_utils.pack_tensor(1234)})).world_name self._connection.send( dm_env_rpc_pb2.JoinWorldRequest(world_name=self._world_name)) step_response = self._connection.send(dm_env_rpc_pb2.StepRequest()) self._connection.send( dm_env_rpc_pb2.ResetRequest( settings={'seed': tensor_utils.pack_tensor(1234)})) self.assertEqual(step_response, self._connection.send(dm_env_rpc_pb2.StepRequest()))
def test_cannot_reset_when_not_joined(self): with self.assertRaises(error.DmEnvRpcError): self._connection.send(dm_env_rpc_pb2.ResetRequest())
def reset(self): """Resets the environment, returning the specs.""" return self.connection.send( dm_env_rpc_pb2.ResetRequest( settings=self.required_reset_settings)).specs