Module lib.elca

elementary cellular automata

Functions

CA.new () constructor
CA:update () update all state
CA:neighbors (i) helper: return three values to use for neighbor code
CA.code (l, c, r) get binary code for value given cell and neighbors
CA:window (n) return 8 cells at current offset
CA:set_rule_by_state (val, l, c, r) change current state at index, and update the rule to that which would have produced the new state
CA:clear () clear all states


Functions

CA.new ()
constructor

Returns:

    elca
CA:update ()
update all state
CA:neighbors (i)
helper: return three values to use for neighbor code

Parameters:

  • i number

Returns:

    tuple of left, right, center
CA.code (l, c, r)
get binary code for value given cell and neighbors

Parameters:

  • l number left cell
  • c number center cell
  • r number right cell
CA:window (n)
return 8 cells at current offset

Parameters:

  • n number

Returns:

    table table with 8 binary values
CA:set_rule_by_state (val, l, c, r)
change current state at index, and update the rule to that which would have produced the new state

Parameters:

  • val
  • l
  • c
  • r
CA:clear ()
clear all states
generated by LDoc 1.4.6 Last updated 2023-11-17 11:40:11