Files
Gymnasium/gym/spaces/multi_binary.py
Xingdong Zuo 6497c9f1c6 Delete prng.py (#1196)
* Delete prng.py

Since it seems like this seeding function is rarely used.

* Update __init__.py

* Update kellycoinflip.py

* Update core.py

* Update box.py

* Update discrete.py

* Update multi_binary.py

* Update multi_discrete.py

* Update test_determinism.py

* Update test_determinism.py

* Update test_determinism.py

* Update core.py

* Update box.py

* Update test_determinism.py

* Update core.py

* Update box.py

* Update discrete.py

* Update multi_binary.py

* Update multi_discrete.py

* Update dict_space.py

* Update tuple_space.py

* Update core.py

* Create space.py

* Update __init__.py

* Update __init__.py

* Update box.py

* Update dict_space.py

* Update discrete.py

* Update dict_space.py

* Update multi_binary.py

* Update multi_discrete.py

* Update tuple_space.py

* Update discrete.py

* Update box.py

* Update dict_space.py

* Update multi_binary.py

* Update multi_discrete.py

* Update tuple_space.py

* Update multi_discrete.py

* Update multi_binary.py

* Update dict_space.py

* Update box.py

* Update test_determinism.py

* Update kellycoinflip.py

* Update space.py
2019-01-30 13:39:55 -08:00

32 lines
775 B
Python

import gym
import numpy as np
from .space import Space
class MultiBinary(Space):
def __init__(self, n):
self.n = n
super().__init__((self.n,), np.int8)
self.np_random = np.random.RandomState()
def seed(self, seed):
self.np_random.seed(seed)
def sample(self):
return self.np_random.randint(low=0, high=2, size=self.n).astype(self.dtype)
def contains(self, x):
return ((x==0) | (x==1)).all()
def to_jsonable(self, sample_n):
return np.array(sample_n).tolist()
def from_jsonable(self, sample_n):
return [np.asarray(sample) for sample in sample_n]
def __repr__(self):
return "MultiBinary({})".format(self.n)
def __eq__(self, other):
return self.n == other.n