Largest Maze on the Internet

Post Reply
User avatar
Mr. Kibernetik
Site Admin
Posts: 4787
Joined: Mon Nov 19, 2012 10:16 pm
My devices: iPhone, iPad, MacBook
Location: Russia
Flag: Russia

Largest Maze on the Internet

Post by Mr. Kibernetik »

According to Walter Pullen, largest mage on the Internet (http://www.astrolog.org/labyrnth/maze.htm) is 5000x5000.
So, I decided to beat this result and made my version of "Largest Maze on the Internet". It is 5555x5555 size and can be downloaded here: https://www.dropbox.com/s/nlapkyhm8j48c ... 5x5555.png

Program to make it is my "A-Maze v3.0":

Code: Select all

'A-maze v3.0
'labyrinth generator
'made in "smart BASIC"
'(c)Mr.Kibernetik, 2014

'settings
maze.width=201
maze.height=201
maze.fastperc=90 'percent of filling when implement fast fill
drawtext=1

maze.wsize=2
scene.width=(maze.width-0.5)*maze.wsize
scene.height=(maze.height-0.5)*maze.wsize
draw size maze.wsize/2
scene
maze

def scene
option screenlock off
graphics
graphics clear
option sprite pos central
sprite 0 begin width,height
'draw labyrinth silhouette
graphics clear 0,0,1
if .drawtext then
  draw color 0,0,0
  if maze.height>=200 then
    draw font size height/10
    t$="made by"
    tx=(width-text_width(t$))/2
    ty=height/3
    draw text t$ at tx,ty
    t$="Mr.Kibernetik"
    tx=(width-text_width(t$))/2
    ty=height/2
    draw text t$ at tx,ty
  else
    draw font size height
    t$="A"
    tx=(width-text_width(t$))/2
    ty=-height/10
    draw text t$ at tx,ty
  end if
end if
sprite end
maxx=screen_width()
maxy=screen_height()
ss=min(maxx/width,maxy/height)
sprite 0 at maxx/2,maxy/2 scale ss
sprite 0 show
end def

def maze
width1=width-1
height1=height-1
size=width*height
dim pt(width,height),grp(size+1)
ss=screen_scale()
sprite 0 begin
refresh off
draw color 0,0,0
draw linecap round
for x=0 to width1
  xs=x*wsize*ss
  for y=0 to height1
    ys=y*wsize*ss
    get pixel xs,ys color r,g,b
    draw pixel xs,ys color 1,1,1
    if r+g+b=0 then continue y
    cnt+=1
    pt(x,y)=cnt
    grp(cnt)=cnt
    next y
  refresh
  next x
randomize
graphics clear 1,1,1
for x=0 to width1
  for y=0 to height1
    if pt(x,y)=0 then continue y
    dn=0 ! d1=0 ! d2=0 ! d3=0 ! d4=0
    if (y>0 and pt(x,y-1)=0) or y=0 then
      dn+=1 ! d3=1
    end if
    if (y<height1 and pt(x,y+1)=0) or y=height1 then
      dn+=1 ! d1=1
    end if
    if (x>0 and pt(x-1,y)=0) or x=0 then
      dn+=1 ! d2=1
    end if
    if (x<width1 and pt(x+1,y)=0) or x=width1 then
      dn+=1 ! d4=1
    end if

    if y=0 and d1 then
      dn-=1 ! d1=0
    end if
    if y=height1 and d3 then
      dn-=1 ! d3=0
    end if
    if x=0 and d4 then
      dn-=1 ! d4=0
    end if
    if x=width1 and d2 then
      dn-=1 ! d2=0
    end if

    if dn=0 then continue y
    if dn=4 then
      cnt-=1
      pt(x,y)=0
      continue y
    end if
    if dn=3 then
      if d1=0 or d3=0 then
        d2=0 ! d4=0 ! goto cont
      end if
      d1=0 ! d3=0 ! goto cont
    end if
    if dn=2 then
      if d1 and d3 then
        d1=0 ! d3=0 ! d2=1 ! d4=1 ! goto cont
      end if
      if d2 and d4 then
        d1=1 ! d3=1 ! d2=0 ! d4=0 ! goto cont
      end if
      goto cont
    end if
    if d1 or d3 then
      d1=0 ! d2=1 ! d3=0 ! d4=1 ! goto cont
    end if
    if d2 or d4 then
      d1=1 ! d2=0 ! d3=1 ! d4=0 ! goto cont
    end if
cont:
    x1=x ! y1=y ! n1=getgrp(pt(x1,y1))
    if n1=0 then continue y
    if d1 then
      x2=x ! y2=y-1 ! n2=getgrp(pt(x2,y2))
      if n2=0 or n1=n2 then continue y
      wall(x1,y1,x2,y2,n1,n2)
    end if
    if d2 then
      x2=x+1 ! y2=y ! n1=getgrp(pt(x1,y1)) ! n2=getgrp(pt(x2,y2))
      if n2=0 or n1=n2 then continue y
      wall(x1,y1,x2,y2,n1,n2)
    end if
    if d3 then
      x2=x ! y2=y+1 ! n1=getgrp(pt(x1,y1)) ! n2=getgrp(pt(x2,y2))
      if n2=0 or n1=n2 then continue y
      wall(x1,y1,x2,y2,n1,n2)
    end if
    if d4 then
      x2=x-1 ! y2=y ! n1=getgrp(pt(x1,y1)) ! n2=getgrp(pt(x2,y2))
      if n2=0 or n1=n2 then continue y
      wall(x1,y1,x2,y2,n1,n2)
    end if
    next y
  refresh
  next x
loop:
if wall.perc>=fastperc then fastfin
x1=rnd(width-2)+1
y1=rnd(height-2)+1
n1=getgrp(pt(x1,y1))
if n1=0 then loop
on rnd(4)+1 gosub 1,2,3,4
n2=getgrp(pt(x2,y2))
if n1=n2 or n2=0 then loop
wall(x1,y1,x2,y2,n1,n2)
goto loop
1 x2=x1 ! y2=y1-1 ! return
2 x2=x1+1 ! y2=y1 ! return
3 x2=x1 ! y2=y1+1 ! return
4 x2=x1-1 ! y2=y1 ! return
fastfin:
width2=width-2
height2=height-2
for x1=1 to width2
  for y1=1 to height2
    n1=getgrp(pt(x1,y1))
    if n1=0 then continue y1
    for i=1 to 4
        on i gosub 1,2,3,4
        n2=getgrp(pt(x2,y2))
        if n1=n2 or n2=0 then continue
        wall(x1,y1,x2,y2,n1,n2)
        n1=getgrp(pt(x1,y1))
        if n1=0 then continue y1
      next i
    next y1
  refresh
  next x1
refresh on
sprite end
f$="laby "&maze.width1&"x"&maze.height1&".png"
sprite 0 save f$
notes set ,,,,,,,,,"wa5"
notes play
pause notes_length()
end
end def

def wall(x1,y1,x2,y2,n1,n2)
px1=x1*maze.wsize
py1=y1*maze.wsize
px2=x2*maze.wsize
py2=y2*maze.wsize

draw line px1,py1 to px2,py2

maze.grp(n2)=n1
maze.pt(x2,y2)=n1
cnt+=1
perc=int(100*cnt/maze.cnt)
if cnt%1000=0 then refresh
end def

def getgrp(n)
no=n
loop:g=maze.grp(n)
if g=n then
  if n<>no then maze.grp(no)=n
  return n
end if
n=g
goto loop
end def

User avatar
Dutchman
Posts: 860
Joined: Mon May 06, 2013 9:21 am
My devices: iMac, iPad Air, iPhone
Location: Netherlands
Flag: Netherlands

Re: Largest Maze on the Internet

Post by Dutchman »

Congratulations!
Have you proven that it can be solved :D
On the attached picture you can see that there is some regular structure in it, on 256 pixels interval in both directions. :roll:
Is it really random?
Attachments
Laby in Photoshop, subsampled
Laby in Photoshop, subsampled
Laby screen shot.png (943.04 KiB) Viewed 5610 times

User avatar
Mr. Kibernetik
Site Admin
Posts: 4787
Joined: Mon Nov 19, 2012 10:16 pm
My devices: iPhone, iPad, MacBook
Location: Russia
Flag: Russia

Re: Largest Maze on the Internet

Post by Mr. Kibernetik »

Thank you! :D
Well, I think that this regularity is made by your viewing software, seems as a result of JPEG compression or something similar. Also you may notice some blurring in the middle of this regular zones.
Meanwhile my image is PNG with 100% quality and should not expose any blurring or regularity.
Compare the same fragment without artifacts:
Снимок экрана 2014-06-30 в 15.11.23.png
Снимок экрана 2014-06-30 в 15.11.23.png (119.96 KiB) Viewed 5609 times

User avatar
rbytes
Posts: 1338
Joined: Sun May 31, 2015 12:11 am
My devices: iPhone 11 Pro Max
iPad Pro 11
MacBook
Dell Inspiron laptop
CHUWI Plus 10 convertible Windows/Android tablet
Location: Calgary, Canada
Flag: Canada
Contact:

Re: Largest Maze on the Internet

Post by rbytes »

Is there a simple way to set the thickness of the maze pathways and boundaries? They are now one pixel thick, but it would be nice to be able to adjust that for kids or people with vision problems. I tried changing a few variables, but didn't get the change I hoped for.
The only thing that gets me down is gravity...

Henko
Posts: 822
Joined: Tue Apr 09, 2013 12:23 pm
My devices: iPhone,iPad
Windows
Location: Groningen, Netherlands
Flag: Netherlands

Re: Largest Maze on the Internet

Post by Henko »

WE HAVE A WORLD CHAMPION!!
What time did it take on what device?

User avatar
Mr. Kibernetik
Site Admin
Posts: 4787
Joined: Mon Nov 19, 2012 10:16 pm
My devices: iPhone, iPad, MacBook
Location: Russia
Flag: Russia

Re: Largest Maze on the Internet

Post by Mr. Kibernetik »

Henko wrote:WE HAVE A WORLD CHAMPION!!
What time did it take on what device?
Every year with new device generation the time is 2x smaller... :D

Operator
Posts: 138
Joined: Mon May 06, 2013 5:52 am

Re: Largest Maze on the Internet

Post by Operator »

:idea: Congrats Mr. K :idea:

@Henko
On my iPhone 4 it takes ~ 197 sec.
Attachments
image.jpg
image.jpg (421.36 KiB) Viewed 4522 times

Post Reply