mirror of
https://github.com/Farama-Foundation/Gymnasium.git
synced 2025-08-30 17:57:30 +00:00
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:
@@ -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)
|
||||
|
Reference in New Issue
Block a user