Make Tuple and Dicts be seedable with lists and dicts of seeds + make the seed in default initialization controllable (#1774)

* Make the seed in default initialization controllable

Since seed() is being called in default initialization of Space, it should be controllable for reproducibility.

* Updated derived classes of Space to have their seeds controllable at initialization.

* Allow Tuple's spaces to each have their own seed

* Added dict based seeding for Dict space; test cases for Tuple and Dict seeding

* Update discrete.py

* Update test_spaces.py

* Add seed to __init__()

* blacked

* Fix black

* Fix failing tests
This commit is contained in:
RaghuSpaceRajan
2021-09-13 20:08:01 +02:00
committed by GitHub
parent 0eabbaf8a2
commit c571b0d853
8 changed files with 123 additions and 45 deletions

View File

@@ -23,7 +23,7 @@ class Box(Space):
"""
def __init__(self, low, high, shape=None, dtype=np.float32):
def __init__(self, low, high, shape=None, dtype=np.float32, seed=None):
assert dtype is not None, "dtype must be explicitly provided. "
self.dtype = np.dtype(dtype)
@@ -81,7 +81,7 @@ class Box(Space):
self.bounded_below = -np.inf < self.low
self.bounded_above = np.inf > self.high
super(Box, self).__init__(self.shape, self.dtype)
super(Box, self).__init__(self.shape, self.dtype, seed)
def is_bounded(self, manner="both"):
below = np.all(self.bounded_below)