mirror of
https://github.com/Farama-Foundation/Gymnasium.git
synced 2025-08-30 01:50:19 +00:00
fix for issue 1256 (Box(low=0, high=255, dtype='uint8').sample() returned zeros) (#1307)
This commit is contained in:
@@ -41,7 +41,8 @@ class Box(Space):
|
||||
self.np_random.seed(seed)
|
||||
|
||||
def sample(self):
|
||||
return self.np_random.uniform(low=self.low, high=self.high + (0 if self.dtype.kind == 'f' else 1), size=self.low.shape).astype(self.dtype)
|
||||
high = self.high if self.dtype.kind == 'f' else self.high.astype('int64') + 1
|
||||
return self.np_random.uniform(low=self.low, high=high, size=self.low.shape).astype(self.dtype)
|
||||
|
||||
def contains(self, x):
|
||||
return x.shape == self.shape and (x >= self.low).all() and (x <= self.high).all()
|
||||
|
Reference in New Issue
Block a user