Skip to content

Commit

Permalink
conditional StreamWrapper
Browse files Browse the repository at this point in the history
Signed-off-by: Mathieu D <[email protected]>
  • Loading branch information
mdreano committed Mar 3, 2024
1 parent 4b4fe06 commit cb89971
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions baselines/baselines_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ def load_or_create_model(model_to_load_path, env_config, total_timesteps, num_cp
return model


def make_env(rank, env_conf, seed=0):
def make_env(rank, env_config, seed=0):
"""
Utility function for multiprocessed env.
:param env_id: (str) the environment ID
Expand All @@ -44,8 +44,18 @@ def make_env(rank, env_conf, seed=0):
:param rank: (int) index of the subprocess
"""
def _init():
env = RedGymEnv(env_conf)
env = RedGymEnv(env_config)
env.reset(seed=(seed + rank))
if env_config['stream'] is True:
env = StreamWrapper(
env,
stream_metadata = { # All of this is part is optional
"user": "MATHIEU", # choose your own username
"env_id": env_config['instance_id'], # environment identifier
"color": "#d900ff", # choose your color :)
"extra": "", # any extra text you put here will be displayed
}
)
return env
set_random_seed(seed)
return _init

0 comments on commit cb89971

Please sign in to comment.