|
|
import numpy as np |
|
|
from env import make_env |
|
|
|
|
|
print("Testing local make_env function...") |
|
|
|
|
|
|
|
|
print("Testing with n_envs=1...") |
|
|
env_vec_n1 = make_env(n_envs=1, use_async_envs=False) |
|
|
obs, info = env_vec_n1.reset() |
|
|
|
|
|
print(f" Reset OK. Observation shape (n_envs=1): {obs.shape}") |
|
|
assert obs.shape == (1, 12) |
|
|
|
|
|
action = env_vec_n1.action_space.sample() |
|
|
obs, _, _, _, _ = env_vec_n1.step(action) |
|
|
print(f" Step OK. Observation shape (n_envs=1): {obs.shape}") |
|
|
assert obs.shape == (1, 12) |
|
|
env_vec_n1.close() |
|
|
print(" n_envs=1 Test Passed.") |
|
|
|
|
|
|
|
|
|
|
|
print("\nTesting with n_envs=2...") |
|
|
env_vec_n2 = make_env(n_envs=2, use_async_envs=False) |
|
|
obs, info = env_vec_n2.reset() |
|
|
|
|
|
print(f" Reset OK. Observation shape (n_envs=2): {obs.shape}") |
|
|
assert obs.shape == (2, 12) |
|
|
|
|
|
action = env_vec_n2.action_space.sample() |
|
|
obs, _, _, _, _ = env_vec_n2.step(action) |
|
|
print(f" Step OK. Observation shape (n_envs=2): {obs.shape}") |
|
|
assert obs.shape == (2, 12) |
|
|
env_vec_n2.close() |
|
|
print(" n_envs=2 Test Passed.") |
|
|
|
|
|
print("\n--- All local tests passed! ---") |
|
|
|