def test_multiagent_mutliproc_single_proc_equivalency(): env = simple_spread_v2.parallel_env() env = pettingzoo_env_to_vec_env_v0(env) num_envs = 3 venv1 = concat_vec_envs_v0( env, num_envs, num_cpus=0) # uses single threaded vector environment venv2 = concat_vec_envs_v0( env, num_envs, num_cpus=4) # uses multiprocessing vector environment check_vec_env_equivalency(venv1, venv2)
def env_fn(): #env = gym.make("CartPole-v0")# env = simple_spread_v2.parallel_env() # print(env.action_spaces.values()) # exit(0) env = supersuit.pad_observations_v0(env) env = supersuit.pad_action_space_v0(env) #env = supersuit.aec_wrappers.continuous_actions(env) venv = pettingzoo_env_to_vec_env_v0(env) return venv
writer = SummaryWriter(f"/tmp/{experiment_name}") # TRY NOT TO MODIFY: seeding device = torch.device( 'cuda' if torch.cuda.is_available() and args.cuda else 'cpu') random.seed(args.seed) np.random.seed(args.seed) torch.manual_seed(args.seed) torch.backends.cudnn.deterministic = args.torch_deterministic # petting zoo env = pistonball_v4.parallel_env() env = ss.color_reduction_v0(env, mode='B') env = ss.resize_v0(env, x_size=84, y_size=84) env = ss.frame_stack_v1(env, 3) env = ss.pettingzoo_env_to_vec_env_v0(env) envs = ss.concat_vec_envs_v0(env, args.num_envs, num_cpus=0, base_class='stable_baselines3') envs = VecMonitor(envs) if args.capture_video: envs = VecVideoRecorder(envs, f'videos/{experiment_name}', record_video_trigger=lambda x: x % 150000 == 0, video_length=400) envs = VecPyTorch(envs, device) args.num_envs = envs.num_envs args.batch_size = int(args.num_envs * args.num_steps) args.minibatch_size = int(args.batch_size // args.n_minibatch) assert isinstance(envs.action_space,
def test_env_is_wrapped_pettingzoo(): env = simple_spread_v2.parallel_env() venv1 = pettingzoo_env_to_vec_env_v0(env) num_envs = 3 venv1 = concat_vec_envs_v0(venv1, num_envs) assert venv1.env_is_wrapped(flatten) == [False] * 9
def make_env(): env = pistonball_v4.parallel_env() env = pettingzoo_env_to_vec_env_v0(env) return env