Zero Mem Life
start = true
width = 127
height = 127
function neighbours(x1,y1)
local value =0
for xx = x1-1,x1+1 do
for yy= y1-1,y1+1 do
local current = pget(xx,yy)
if ( current == 5 or current == 6) then
if (xx ~= x1 or yy ~= y1) then
value = value +1
end
end
end
end
return value
end
function nextcell(x,y)
count = neighbours(x,y)
col = pget(x,y)
if (col == 0 and count == 3) then
-- cell is born as white
pset(x,y,7)
end
if (col == 5) then
if (count == 2 or count == 3) then
-- cell lives on as a light grey
pset(x,y, 6)
end
end
end
function _draw()
if (start) then cls(0)
for x=0,width/2 do
for y=0,height/2 do
if (flr(rnd(3))== 0) then
-- 1 in 3 cells should be alive
pset(x+width/4,y+width/4,7)
else
pset(x+width/4,y+width/4,0)
end
end
end
start = false
else
for x=0,width do
for y = 0,height do
if(pget(x,y) == 7) then
-- age a cell on the screen from dark grey to grey
pset(x,y, 5)
end
end
end
for x=0,width do
for y=0,height do
nextcell(x,y)
end
end
for x=0,width do
for y=0,height do
col = pget(x,y)
if (col == 6) then
-- age cell from light grey to white
pset(x,y,7)
end
if (col==5) then
-- dark grey cells dies
pset(x,y,0)
end
end
end
end
end
What?
Zero Mem Life was a thought exercise in making a game of life simulator in Pico8 without using memory other than the screen to store cell state. It's otherwise unoptimised and written in a verbose style.
Why?
I'm using it to understand how to upload projects to Itch.
| Status | Released |
| Platforms | HTML5 |
| Author | Anomalous Things |
| Genre | Simulation |
| Made with | PICO-8 |
| Tags | Automation, Life Simulation, PICO-8 |
Leave a comment
Log in with itch.io to leave a comment.