Module lib.elca
elementary cellular automata
Functions
new () | constructor |
update () | update all state |
neighbors (i) | helper: return three values to use for neighbor code |
code (l, c, r) | get binary code for value given cell and neighbors |
window (n) | return 8 cells at current offset |
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 |
clear () | clear all states |
Functions
- new ()
-
constructor
Returns:
-
elca
- update ()
- update all state
- neighbors (i)
-
helper: return three values to use for neighbor code
Parameters:
- i number
Returns:
-
tuple of left, right, center
- 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
- window (n)
-
return 8 cells at current offset
Parameters:
- n number
Returns:
-
table
table with 8 binary values
- 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
- clear ()
- clear all states