Log In  


This is a maze generator in 191 characters.

Cart #maze_gen_191-0 | 2024-07-03 | Code ▽ | Embed ▽ | License: CC4-BY-NC-SA
3

t={-2,2}function g(x,y)if(pget(x,y)<7)return
line(x,y)::l::r=rnd(t)if(rnd(2)>1)then
g(x+r,y)else
g(x,y+r)end
line(x,y)if(rnd(99)>1)goto l
end
cls(7)g(0,0)pal(7,8,1)pal(6,7,1)::_::flip()goto _

This is my first time doing this, let me know if it could be improved.

3


Depends on what your challenge is.
Your current code is readable, are you you willing to renounce that?
Do you want less characters ? you could do r=rnd({-2,2}) or remove flip() for example.
Do you want more speed ? change the rnd(99) to a lower value. You could probably get a maze instantly if you don't mind getting a few unreached intersections.
Maybe you want to add something ? Like a maze solver or colored pixels chasing each-other for example?
What is the upper limit of character for your challenge ?


@RealShadowCaster Mainly it was just for fun, as I hadn't tried this before! Yeah, I could do r=rnd{-2,2} but then the name wouldn't match the number of characters =p



[Please log in to post a comment]