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')
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')