it fixes the issue I believe that the Hashlife algorithm could help you. It gives the idea of using a quadtree (tree data structure in which each internal node has exactly four children) to keep the data, and then it uses hash tables to store the nodes of the quadtree.
help you fix your problem Here's one obvious way of doing this. You simply create a new instance of Cell and store its state (as :dead or :alive). dead? and alive? methods then simply check the state.
ALIVE = :alive
DEAD = :dead
def initialize state
@state = state
state == DEAD
state == ALIVE
I think the issue was by ths following , Your program cannot work correctly in its current state, because you compute the next generation in the same grid where the last generation is stored. You need a new (empty) grid to store the next generation. In your implementation you overwrite the last generation already while computing the next generation.
This might help you I don't have pygame installed, so I can't run your code. However, the bug that's causing your error is that you don't reset a cell's neighbour count to zero after you've determined whether it'll be alive or dead in the next generation. So in each generation each cell's new neighbour count gets added to the previous accumulated neighbour count. You should probably do that resetting in the .breed method. Here's a more compact version of that method:
self.alive = self.neighbours == 3 or self.alive and self.neighbours == 2
self.neighbours = 0
CELL_LIST = 
for y, row in enumerate(CELL_MAP):
for x, v in enumerate(row):
CELL_LIST.append(Cell(v == 1, x, y))
CELL_LIST = [Cell(bool(v), x, y)
for y, row in enumerate(CELL_MAP)
for x, v in enumerate(row)
cell_list = [[Cell(bool(v), x, y) for x, v in enumerate(row)]
for y, row in enumerate(CELL_MAP)]