from .base import TohuBaseGenerator

__all__ = ['Constant', 'PrimitiveGenerator']


class PrimitiveGenerator(TohuBaseGenerator):
    """
    Base class for all primitive generators
    """


class Constant(PrimitiveGenerator):
    """
    Generator which produces a constant sequence (repeating the same value indefinitely).
    """

    def __init__(self, value):
        """
        Parameters
        ----------
        value:
            The constant value produced by this generator.
        """
        super().__init__()
        self.value = value

    def reset(self, seed=None):
        super().reset(seed)
        return self

    def __next__(self):
        return self.value

    def spawn(self):
        return Constant(self.value)

    def _set_random_state_from(self, other):
        pass

@@ -1,12 +1,38 @@
+from random import Random%0A
 from .base i
@@ -67,16 +67,27 @@
 ll__ = %5B
+'Boolean', 
 'Constan
@@ -834,8 +834,700 @@
    pass%0A
+%0A%0Aclass Boolean(PrimitiveGenerator):%0A    %22%22%22%0A    Generator which produces random boolean values (True or False).%0A    %22%22%22%0A%0A    def __init__(self, p=0.5):%0A        %22%22%22%0A        Parameters%0A        ----------%0A        p: float%0A            The probability that True is returned. Must be between 0.0 and 1.0.%0A        %22%22%22%0A        super().__init__()%0A        self.p = p%0A        self.randgen = Random()%0A%0A    def reset(self, seed):%0A        super().reset(seed)%0A        self.randgen.seed(next(self.seed_generator))%0A        return self%0A%0A    def _set_random_state_from(self, other):%0A        self.randgen.setstate(other.randgen.getstate())%0A%0A    def __next__(self):%0A        return self.randgen.random() %3C self.p%0A

Add Boolean generator