def __len__(self):
        return self.width*self.height

    def __iter__(self):
        return self

    def __next__(self):

        # Get state at current time, then increment time
        state = self.world[self.time]
        self.time += 1

        # Halting condition
        if self.time >= self.height:
            raise StopIteration()

        # Calculate the world at this timestep
        self.world[self.time] = np.array(list(self.compute_states(state)))
        return self.world[self.time]
    next = __next__



if __name__ == '__main__':
    from animation import AutomataAnimation
    #automata  = Automata(110, width=1280, height=720, randstart=False)
    automata  = Automata(110, width=100, height=100, randstart=True)
    animation = AutomataAnimation(automata)
    animation.show()
Exemple #2
0
    def __len__(self):
        return self.width * self.height

    def __iter__(self):
        return self

    def __next__(self):

        # Get state at current time, then increment time
        state = self.world[self.time]
        self.time += 1

        # Halting condition
        if self.time >= self.height:
            raise StopIteration()

        # Calculate the world at this timestep
        self.world[self.time] = np.array(list(self.compute_states(state)))
        return self.world[self.time]

    next = __next__


if __name__ == '__main__':
    from animation import AutomataAnimation
    #automata  = Automata(110, width=1280, height=720, randstart=False)
    automata = Automata(110, width=100, height=100, randstart=True)
    animation = AutomataAnimation(automata)
    animation.show()