BACK

>./CELLULAR_AUTOMATA

I made this after watching a Steve Mould video on Excitable Media, which I then learned could be represented with cellular automata. I thought the idea was cool, and it reminded me of the Belousov-Zhabotinsky reaction, so I wanted to make one. Turns out, onces you have one cellular automata set up, it's pretty easy to just, make another. Or generalize it. I did that.


WIP. Will include:

  • A few automata presets
  • Customizable palettes
  • Proper documentation

(Click the cells to change the palette, btw.)

/* This JS code is run once per cell (100x100 = 10000 calls per frame. Be mindful.). variables: x: X position of the cell y: Y position of the cell cell: The original cell. It is advised you make a new cell as seen below. getCell(x, y): Gets a cell based on the coordinates. max_value: The highest state a cell can be in (based on the palette) Review the below code to get some ideas. */ let new_cell = { state: cell.state }; if(cell.state > 0) { new_cell.state = cell.state - 1; return new_cell; } for(let offsetX of [-1, 1]) { if(getCell(x + offsetX, y).state == max_value) { new_cell.state = max_value; return new_cell; } } for(let offsetY of [-1, 1]) { if(getCell(x, y + offsetY).state == max_value) { new_cell.state = max_value; return new_cell; } } if(Math.trunc(Math.random() * 10000) == 69) { new_cell.state = max_value; } return new_cell;
This page requires Javascript to render. Sorry.