Another ant-based cellular automata
Posted: January 18th, 2019, 2:28 am
https://codepen.io/anon/pen/vvqNqg
These rule makes mysterious path!
These rule makes mysterious path!
Forums for Conway's Game of Life
https://conwaylife.com/forums/
Code: Select all
function next_step()
{
var dx = x_shift[ant_d];
var dy = y_shift[ant_d];
var cx = (ant_x+dx+w)%w;
var cy = (ant_y+dy+h)%h;
var a = cy*w+cx;
var s = currc[a];
if (s)
ant_d = (ant_d + 3) % 4
else
ant_d = (ant_d + 1) % 4
currc[ant_y*w+ant_x] = 1 - s;
ant_x = cx;
ant_y = cy;
Code: Select all
var ant_x = (w / 2) | 0;
var ant_y = (h / 2) | 0;
var ant_d = 0;
var currc = new Uint8Array(w*h);
var x_shift = [1,0,-1,0];
var y_shift = [0,1,0,-1];