Bitbucket is a code hosting site with unlimited public and private repositories. We're also free for small teams!

Close

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 
           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
    

Recent activity

Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.