mirror of
https://github.com/Farama-Foundation/Gymnasium.git
synced 2025-08-31 18:12:53 +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:
@@ -11,10 +11,10 @@ class Discrete(Space):
|
||||
|
||||
"""
|
||||
|
||||
def __init__(self, n):
|
||||
def __init__(self, n, seed=None):
|
||||
assert n >= 0
|
||||
self.n = n
|
||||
super(Discrete, self).__init__((), np.int64)
|
||||
super(Discrete, self).__init__((), np.int64, seed)
|
||||
|
||||
def sample(self):
|
||||
return self.np_random.randint(self.n)
|
||||
|
Reference in New Issue
Block a user