from gymnasium.spaces import MultiDiscrete
[docs]class BPObservationSpace(MultiDiscrete):
"""
A base class used to represent a BProgram-based observation space. This is an abstract class
that requires the implementation of `bp_state_to_gym_space` methods.
"""
@property
def np_random(self):
return super().np_random
@property
def shape(self):
return super().shape
[docs] def seed(self, seed=None):
return super().seed(seed)
[docs] def contains(self, x):
pass
def __contains__(self, x):
return super().__contains__(x)
def __setstate__(self, state):
super().__setstate__(state)
[docs] def to_jsonable(self, sample_n):
return super().to_jsonable(sample_n)
[docs] def from_jsonable(self, sample_n):
return super().from_jsonable(sample_n)
[docs] def bp_state_to_gym_space(self, bthreads_states):
"""
Abstract method that transforms the bprogram's state, received as a list of bthreads statements, to a gym space
representation.
"""
raise NotImplementedError("bp_state_to_gym_space not implemented")