Matrix Light

The Purpose

The purpose of this package is to serve as a lightweight 2D array.

Example Use

  • 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 
        2. Any live cell with two or three live neighbours lives on to the next 
        3. Any live cell with more than three live neighbours dies, as if by 
        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]
                    new_grid[i][j] = DEAD[neighbours]
        return new_grid