Search code examples
pythonpython-2.7conways-game-of-life

Problems with Game Of Life in python


I'm working on Conway's Game of Life in python 2.7, and I'm getting an error I don't understand. In my algorithm to get the number of neighboring tiles that are True, I'm getting an index error.

if column < thesize:
    if board[row][column+1] == True:
        adjacents += 1
return adjacents

thesize is a variable used for generating the 2D grid, so that first line should prevent the error... But it doesn't. The full code is here, can anyone point out my mistake? If the link doesn't work, please let me know.


Solution

  • A sequence with a length of n has a maximum element index of n - 1. Nonetheless you're trying to access element n - 1 + 1, which doesn't exist.