Example #1
0
        return self

    def __next__(self):
        self.time += 1

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

        # Save the current world state
        self.state = np.copy(self.world)
        for row in xrange(self.height):
            for col in xrange(self.width):
                if odd_parity(self.neighborhood(row, col)):
                    self.world[row, col] = 1
                else:
                    self.world[row, col] = 0

        return self.world
    next = __next__

if __name__ == '__main__':
    from animation import AutomataAnimation
    from draw import draw_grid
    automata  = Automata(width=100, height=100, randstart=False)
    #automata.next()
    animation = AutomataAnimation(automata, interval=300)
    #draw_grid(automata.world)
    #animation.show()
    animation.save('odd_parity.mp4')
Example #2
0
    def __next__(self):
        self.time += 1

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

        # Save the current world state
        self.state = np.copy(self.world)
        for row in xrange(self.height):
            for col in xrange(self.width):
                if odd_parity(self.neighborhood(row, col)):
                    self.world[row, col] = 1
                else:
                    self.world[row, col] = 0

        return self.world

    next = __next__


if __name__ == '__main__':
    from animation import AutomataAnimation
    from draw import draw_grid
    automata = Automata(width=100, height=100, randstart=False)
    #automata.next()
    animation = AutomataAnimation(automata, interval=300)
    #draw_grid(automata.world)
    #animation.show()
    animation.save('odd_parity.mp4')
Example #3
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()
Example #4
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()