simple 2 player chess game for #pico1k jam. pseudo-legal implementation which ignores en-passant, castling and promotion.

full code (1022 chars):

poke(0x5f2d,1)h=stat b={}n=-1 r=circ for k=0,63do b[k]=ord('rnbqkbnrpppppppp________________________________PPPPPPPPRNBQKBNR',k+1)end function z(x)return-sin(x/abs(x*4))end::_::cls()w={}for k=0,63do p=b[k]x,y=k%8,k\8rectfill(x*16,y*16,x+1<<4,y+1<<4,(x^^y)&1==0and 12or 1) ?p==95and' 'or chr(p),x*16+7,y*16+6,p>95 and 0or 7 if i==k then function a(s,t,f) if((s|t)&~0x7!=0)return j=s+t*8l=z(s-x)+8*z(t-y)c=z(b[j]-95)for m=i+l,j-l,l do if(f&1>0and b[m]!=95)return end if(f&4>0and c==0or f&2>0and c==-n)w[i*64+j]=1end if(n>0)p-=32 if(p==80)a(x,y+n,4)a(x+1,y+n,2)a(x-1,y+n,2)a(x,y+(y-2&~0x3!=0and 2*n or 0),5) for g=0,.75,.25do u=cos(g)v=sin(g) if(p==78)a(x+u-v*2,y+v+u*2,6)a(x-u-v*2,y+u*2-v,6) if(p==75)a(x+u,y+v,6)a(x+u-v,y+u+v,6) for d=1,7do if(p==66or p==81)a(x+d*u-d*v,y+d*v+d*u,7) if(p==82or p==81)a(x+d*u,y+d*v,7)end end end end x=h(32)y=h(33)k=h(34)if m==0and k>0then j=x\16+y\16*8if i then if(w[i*64+j])b[j]=b[i]b[i]=95 n=-n i=nil else if(z(b[j]-95)==n)i=j end end m=k r(x,y,3) if(i)r(i%8*16+8,i\8*16+8,5) flip()goto _

Comments

Log in with itch.io to leave a comment.

WOW

TANEK YOU

(+1)

Wow... how on earth did you get CHESS rules in these chars?!
Plays great - nice one! 🤓👌