One-dimensional cellular automata: Difference between revisions

Content added Content deleted
Line 668: Line 668:


function rules(integer tri)
function rules(integer tri)
if tri = 3 or tri = 5 or tri = 6 then
return tri = 3 or tri = 5 or tri = 6
return 1
else
return 0
end if
end function
end function


function next_gen(atom gen)
function next_gen(atom gen)
atom new, bit
atom new, bit
new = rules(and_bits(gen,3)*2) -- work with the first bit separately
new = 0

new += rules(and_bits(gen,3)*2) -- work with the first bit separately
bit = 2
bit = 2
while gen > 0 do
while gen > 0 do