Global

Members

glider :Array.<Array.<number>>

Variable to hold the shape of a glider, an oscilating pattern which translates across the page.
Type:
  • Array.<Array.<number>>
Source:

gliderGun :Array.<Array.<number>>

Variable to hold the shape of a Gosper Glider Gun. This is interesting as it proves that a finite number of cells can replicate indefinietly.
Type:
  • Array.<Array.<number>>
Source:

grid1 :Array.<Array.<number>>

Used to hold the state of all cell sites in the simulation.
Type:
  • Array.<Array.<number>>
Source:

grid2 :Array.<Array.<number>>

Used to hold the state of all cell sites in the simulation.
Type:
  • Array.<Array.<number>>
Source:

gridX :number

Stores the width of the simulation grid
Type:
  • number
Source:

gridY :number

Stores the height of the simulation grid
Type:
  • number
Source:

lightSpaceShip :Array.<Array.<number>>

Variable to hold the shape of a light weight space ship, an oscilating pattern which translates across the page.
Type:
  • Array.<Array.<number>>
Source:

paused :boolean

Flag to see if the simulation has been paused.
Type:
  • boolean
Source:

selectedInsertion :string

What type of object will be inserted when the mouse is clicked.
Type:
  • string
Source:

size :number

Stores the size of one grid cell
Type:
  • number
Source:

updateRate :number

The interval number of frames between simulation updates.
Type:
  • number
Source:

usingGrid1 :boolean

Stores which grid is currently being displayed. This allows for the rules to be applied on the sites of the alternate grid without changing the sites that are being read.
Type:
  • boolean
Source:

Methods

clearGrid()

Removes all live cells from the grid.
Source:

draw()

p5.js draw function, draws cells on the canvas and updates the simulation based on updateRate.
Source:

drawMenu()

Draws the menu with the keyboard operations on the side of the canvas.
Source:

keyPressed()

Handles key presses. Will either switch the global selectedInsertion variable, pause the simulation of clear the screen.
Source:

mousePressed()

Will insert the selected object at the mouse location. Will wrap cells that go over the edge to the other side of the screen.
Source:

neighbours(grid, x, y) → {number}

Function to get the number of live neighbours around a certain cell. If the cell is at the edge this function will automatically wrap around to the other side of the grid.
Parameters:
Name Type Description
grid Array.<Array.<number>> The array on which the neighbours shall be counted.
x number The coloumn for the cell that will be checked
y number The row for the cell that will be checked
Source:
Returns:
- How many cells are alive around the given cell.
Type
number

randomiseGrid()

Randomly kills or inserts cells at every point on the grid. There is a 50 percent chance of either occurence.
Source:

setup()

p5.js setup function, creates canvas and randomises grid1 and grid2.
Source:

Documentation generated by JSDoc 3.6.3 on Sun Jun 05 2022 20:13:18 GMT+0100 (BST)