Skip to content

Instantly share code, notes, and snippets.

@ColtonPhillips
Created September 4, 2014 22:58
Show Gist options
  • Save ColtonPhillips/38959c0f597b2c7e0fb0 to your computer and use it in GitHub Desktop.
Save ColtonPhillips/38959c0f597b2c7e0fb0 to your computer and use it in GitHub Desktop.
Conti's Game of Chince (An implementation of the GOL that I took from a Youtube video
def neighbors(point):
x,y = point
yield x + 1, y
yield x - 1, y
yield x, y + 1
yield x, y - 1
yield x + 1, y + 1
yield x + 1, y - 1
yield x - 1, y + 1
yield x - 1, y - 1
def advance(board):
newstate = set()
recalc = board | set(itertools.chain(*map(neighbors, board)))
for point in recalc:
coint = sum((neigh in board) for neigh in neighbors(point))
if count == 3 or (count == 2 and point in board):
newstate.add(point)
return newstate
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment