It is a growing labyrinth:
Code: Select all
'Maze Automata
'mod by Mr.K
is=5! bs=10
xs=int(screen_width()/bs)
ys=int(screen_height()/bs)
dim p(xs,ys)
graphics
shadow on
FOR x=xs/2-is TO xs/2+is
  FOR y=ys/2-is TO ys/2+is
    p(x,y)=rnd(2)
    NEXT y
  NEXT x
loop:change=0
FOR x=1 TO xs-2
  FOR y=1 TO ys-2
    n=p(x-1,y-1) + p(x,y-1) + p(x+1,y-1) + p(x-1,y) + p(x+1,y) + p(x-1,y+1) + p(x,y+1) + p(x+1,y+1)
    IF p(x,y)=1 AND (n<1 OR n>4) THEN
      p(x,y)=0
      change=1
      continue y
    END IF
    IF p(x,y)=0 AND n=3 THEN
      p(x,y)=1
      change=1
    END IF
    NEXT y
  NEXT x
graphics lock
graphics clear
for x=1 to xs-2
  for y=1 to ys-2
    x1=x*bs! y1=y*bs! x2=x1+bs! y2=y1+bs
    if p(x,y) then fill rect x1,y1 to x2,y2
    next y
  next x
graphics unlock
IF change THEN loop

