The purpose of this package is to serve as a lightweight 2D array.
As a board for a game of life simulation.
#============================================================================== def life(grid): """ 1. Any live cell with fewer than two live neighbours dies, as if caused by under-population. 2. Any live cell with two or three live neighbours lives on to the next generation. 3. Any live cell with more than three live neighbours dies, as if by overcrowding. 4. Any dead cell with exactly three live neighbours becomes a live cell, as if by reproduction. """ new_grid = matrix.Matrix(grid.x, grid.y) for i in range(grid.x): for j in range(grid.y): neighbours = live_neighbours(i, j, grid) if (grid[i][j]): new_grid[i][j] = LIVE[neighbours] else: new_grid[i][j] = DEAD[neighbours] return new_grid