Example #1
0
    def __init__(
        self,
        obsv=[(-1, -1), (-1, 0), (-1, 1), (0, -1), (0, 1), (1, -1), (1, 0), (1, 1), (0, 0)],
        initcfgdb="DB('image.maths.random',resolution=(64,64),amplitude=2)",
        stopcriterion=50,
        rule=lambda st: (min((st.sum() - 2), 1) if st[:-1].sum() in [2, 3] else 0),
        outputf=lambda x: x * 255,
    ):
        self.initcfgdb = pycvf_builder(initcfgdb) if type(initcfgdb) in [str, unicode] else initcfgdb
        self.obsv = obsv
        self.stopcriterion = stopcriterion
        self.rule = rule
        self.mo = make_observation(self.obsv, "torus")
        self.outputf = outputf
        if type(self.stopcriterion) in [int, long]:

            def stop_after_iterations(*args):
                for i in range(stopcriterion):
                    yield False
                yield True

            xe = stop_after_iterations()
            self.stopcriterion = lambda x: xe.next()
Example #2
0
def obs(x, *args, **kwargs):
    return make_observation(*args, **kwargs)(x)