Created
July 24, 2012 03:19
-
-
Save mutaku/3167814 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def runsimulation(f): | |
def checkrun(): | |
if len(changestate) >= 3 and changestate[-3] == changestate[-1]: | |
m("stuck in loop") | |
elif not len(changestate) or changestate[-1]: | |
f() | |
else: | |
m(len(changestate), " state changes - finished.") | |
return checkrun | |
@runsimulation | |
def simulate(): | |
for square in grid: | |
if amialive(square): | |
grid[square] = (grid[square][0], 1) | |
else: | |
grid[square] = (grid[square][0], 0) | |
box = Box(square) | |
changecolor(box, n=1) | |
changestate.append([]) | |
for square in grid: | |
if grid[square][0] != grid[square][1]: | |
changestate[-1].append(square) | |
grid[square] = (grid[square][1], 0) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment