def test_gym_wrapper(): gym_env = gym.make("Acrobot-v1") wrapped = Wrapper(gym_env) assert isinstance(wrapped, Model) assert wrapped.is_online() assert not wrapped.is_generative() wrapped.reseed() # calling some gym functions wrapped.close() wrapped.seed()
def test_double_wrapper_copy_reseeding(ModelClass): env = Wrapper(Wrapper(ModelClass())) seeder = Seeder(123) env.reseed(seeder) c_env = deepcopy(env) c_env.reseed() if deepcopy(env).is_online(): traj1 = get_env_trajectory(env, 500) traj2 = get_env_trajectory(c_env, 500) assert not compare_trajectories(traj1, traj2)
def test_gym_copy_reseeding(): seeder = Seeder(123) if _GYM_INSTALLED: gym_env = gym.make("Acrobot-v1") env = Wrapper(gym_env) env.reseed(seeder) c_env = deepcopy(env) c_env.reseed() if deepcopy(env).is_online(): traj1 = get_env_trajectory(env, 500) traj2 = get_env_trajectory(c_env, 500) assert not compare_trajectories(traj1, traj2)
def test_wrapper_seeding(ModelClass): env1 = Wrapper(ModelClass()) seeder = Seeder(123) env1.reseed(seeder) env2 = Wrapper(ModelClass()) seeder = Seeder(456) env2.reseed(seeder) env3 = Wrapper(ModelClass()) seeder = Seeder(123) env3.reseed(seeder) if deepcopy(env1).is_online(): traj1 = get_env_trajectory(env1, 500) traj2 = get_env_trajectory(env2, 500) traj3 = get_env_trajectory(env3, 500) assert not compare_trajectories(traj1, traj2) assert compare_trajectories(traj1, traj3)