Skip to main content

Indie game storeFree gamesFun gamesHorror games
Game developmentAssetsComics
SalesBundles
Jobs
TagsGame Engines
A jam submission

Wireworld 1KView project page

A wireworld cellular automaton binary adder implemented in Pico-8
Submitted by Wesley — 22 days, 5 hours before the deadline
Add to collection

Play cellular automaton

Wireworld 1K's itch.io page

Compressed Bytes used
1019

Source Code (OPTIONAL)
w,h=100,15
ini=split"32,26,20,14,8,2"
oui=split"91,85,79,73,67,61"
function bits(n,y,i)
i=1
while n>0 do
r=n%2
n=(n-r)/2
if r==1 then
x=ini[i]
ww[y][x]=12
ww[y][x-1]=7
end
i+=1
end
end
function _init()
poke(0x5f5c,30)
poke(0x5f5d,30)
ww={}
tf={a=12,b=7,c=9}
r=split"2c4.2c4.2c4.2c4.2c4.2c15.6c,46.c6.c5.2c4.2c4.2c4.2c4.2c4.2c4.2c,37c5.4c2.2c2.4c,37.c3.c5.c2.b.c2.42c,4c2.c.c4.2c3.c.c3.2c5.c4.4c.c3.c.2ca2.4c,.c.c2.c.2c3.2c3.3c4.c5.c4.c2.2c.5c6.c3.c.c.c2.4c3.c.c4.2c3.c.c3.2c5.c,2c.2c.c.2c3.2c5.c4.2c4.c4.4c.c3.c.c4.c4.5c3.c.c3.c.2c3.2c3.3c4.c5.c,37.c3.c5.c3.c5.2c2.c2.2c.2c2.c.2c3.2c5.c4.2c4.c,38c2.3c3.3c.c,38.c2.c5.c2.c,2c4.2c4.2c4.2c4.2c4.2c6.c.c.c3.c.2c,38.c.c.c3.c.c,39.c2.c2.3c,42.c3.c,43.3c"
for y=1,#r do
ww[y]={}
d=r[y]
m=""
for x=1,#d do
v=d[x]
if tonum(v) then
m..=v
else
p=tonum(m) or 1
for n=1,p do
add(ww[y],tf[v] or 3)
end
m=""
end
end
end
tm=1
fx=1
st=""
end
function _update()
tm-=1/2
if fx==0 and tm<0 then
print"\ac1g"
tm=btn()>0 and 0 or 1
ti+=1
cp={}
for y=1,h do
cp[y]={}
for x=1,w do
cp[y][x]=tnb(x,y,ww[y][x])
end
end
ww=cp
if ti==66 then
fx=1
ans="="..a+b
end
elseif btnp()>0 then
if fx==1 then
ans=nil
ti=0
fx=2
a=flr(rnd(63))
b=nil
bits(a,3)
st="rolling dice"
elseif fx==2 then
fx=3
b=flr(rnd(63))
bits(b,9)
elseif fx==3 then
st=""
fx=0
end
end
end
function _draw()
cls(3)
print("\^pwireworld",1,1,10)
print("binary adder",74,5,11)
print("\^ipico-1k jam 2022",30,14,15)
print(st,4,122,7)
for y=1,h do
for x=1,w do
pset(x+13,y+60,ww[y][x] or 3)
end
end
print(a or "",5,59,14)
if(a)print("+",2,64,14)
print(b or "",5,69,14)
print(ans or "",112,61,11)
if fx==0 and flr(time())%2==0 then print("working",4,122,10)end
end
function tnb(x,y,o,c)
if o==12 then return 7
elseif o==7 then return 9
elseif o~=9 then return o end
c=0
for a=-1,1 do
for b=-1,1 do
if ww[y+a] and ww[y+a][x+b]==12 then
c+=1
end
end
end
return c>0 and c<3 and 12 or o
end

Leave a comment

Log in with itch.io to leave a comment.

Comments

HostSubmitted

This is fascinating!
Seeing the mechanics of all the very things we take for granted and use every day, being recreated in PICO-8 (and in <1K at that), is very impressive.
Nice work 🤓👍