Options
All
  • Public
  • Public/Protected
  • All
Menu

Class Automata

Cellular Automata Class containing all logic to update and display the Grid

Hierarchy

  • Automata

Index

Constructors

constructor

Properties

cols

cols: number = 25

Number of columns in the Automata Grid

grid

grid: Grid = []

Grid of the Cellular Automata

Private iteration

iteration: number = 0

Iteration Number of the Simulation

maxIterations

maxIterations: number = 500

Upper Bound of iteration

msPerStep

msPerStep: number = 100

Number of milliseconds between updates

rows

rows: number = 25

Number of rows in the Automata Grid

rules

rules: Rule[] = []

State Rules of the Cellular Automaton

running

running: boolean = false

Whether the simulation is running

Methods

Private calculateTotalWeight

  • calculateTotalWeight(): number
  • Helper function that calculates the total Weight from InitCell Array

    Returns number

    total Sum of all the weights

Private checkRules

generateGrid

  • generateGrid(fill?: boolean): Grid
  • Generates a Grid based on InitialRules

    Parameters

    • Default value fill: boolean = true

      Whether to fill based on rules or defaultCell

    Returns Grid

    tempGrid which is always decoupled from the Automata Object

Private getNeighbors

  • Helper Function that calculates total neighbor count as well as Type and Quantity of neighbors

    Parameters

    • row: number

      Row of Cell in Grid

    • col: number

      Column of Cell in Grid

    Returns NeighborInfo

    Record of Neighbors and Count as well as Total Count

Private getRandomCell

  • getRandomCell(totalWeight: any): Cell
  • Helper function that randomly selects a Cell based on weight from calculateTotalWeight

    Parameters

    • totalWeight: any

      Sum of all the weights

    Returns Cell

    Cell that falls under the weight's category

printGrid

  • printGrid(): void
  • Prints iteration as well as String Representation of the Grid

    Returns void

run

  • run(): Promise<void>

Private sleep

  • sleep(): Promise<void>

toString

  • toString(): string

updateGrid

  • updateGrid(): void

Object literals

defaultCell

defaultCell: object

Default Blank State that can be modified

display

display: string = "0"

state

state: number = 0

options

options: object

See Options for more details

random

random: boolean = false

range

range: object[] = [{ cell: this.defaultCell, weight: 1 }]