mirror of
https://github.com/saymrwulf/stable-baselines3.git
synced 2026-11-18 09:54:10 +00:00
Add seeding for subproc vecenv
This commit is contained in:
parent
4a79f7e5a7
commit
aa7b91333e
1 changed files with 11 additions and 0 deletions
|
|
@ -188,6 +188,17 @@ class SubprocVecEnv(VecEnv):
|
||||||
for remote in target_remotes:
|
for remote in target_remotes:
|
||||||
remote.recv()
|
remote.recv()
|
||||||
|
|
||||||
|
def seed(self, seed, indices=None):
|
||||||
|
"""
|
||||||
|
:param seed: (int or [int])
|
||||||
|
:param indices: ([int])
|
||||||
|
"""
|
||||||
|
indices = self._get_indices(indices)
|
||||||
|
if not hasattr(seed, 'len'):
|
||||||
|
seed = [seed] * len(indices)
|
||||||
|
assert len(seed) == len(indices)
|
||||||
|
return [self.env_method('seed', seed[i], indices=i) for i in indices]
|
||||||
|
|
||||||
def env_method(self, method_name, *method_args, **method_kwargs):
|
def env_method(self, method_name, *method_args, **method_kwargs):
|
||||||
"""Call instance methods of vectorized environments."""
|
"""Call instance methods of vectorized environments."""
|
||||||
indices = method_kwargs.get('indices')
|
indices = method_kwargs.get('indices')
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue