Skip to content

Instantly share code, notes, and snippets.

@mutaku
Created July 24, 2012 03:19
Show Gist options
  • Save mutaku/3167814 to your computer and use it in GitHub Desktop.
Save mutaku/3167814 to your computer and use it in GitHub Desktop.
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