4 ms·
Show HN: Maze Generation Visualization
- _the_inflator 4y agoI could watch this for hours. :)
- pkstn 4y agoHaha, me too :D
- xabi 4y agoMy three different versions I did long time ago in Perl: https://github.com/xa-bi/mazes https://github.com/xa-bi/mazes
- pkstn 4y agoCool!
- tromp 4y agoOr compile char*M,A,Z,E=40,J[40],T[40];main(C){for(*J=A=scanf(M="%d",&C); -- E; J[ E] =T [E ]= E) printf("._"); for(;(A-=Z=!Z) || (printf("\n|" ) , A = 39 ,C -- ) ; Z || printf (M ))M[Z]=Z[A-(E =A[J-Z])&&!C & A == T[ A] |6<<27<rand()||!C&!Z?J[T[E]=T[A]]=E,J[T[A]=A-Z]=A,"_.":" |"];} with -fwritable-strings -Wno-implicit-function-declaration and watch a maze of the input height being generated on the fly.
- tetris11 4y ago> gcc: error: unrecognized command-line option ‘-fwritable-strings’; did you mean ‘-Wwrite-strings’? this doesn't work with gcc 4 > GCC no longer accepts the -fwritable-strings option. Use named character arrays when you need a writable string. https://gcc.gnu.org/gcc-4.0/changes.html https://gcc.gnu.org/gcc-4.0/changes.html
- tromp 4y agoClang still accepts -fwritable-strings. For gcc, writable strings can be avoided by making the top line one character longer: char M[3],A,Z,E=40,J[40],T[40];main(C){for(*J=A=scanf("%d",&C);
- johnfarrelldev 4y agoIf you're into maxes and coding you should check out: http://www.mazesforprogrammers.com/ http://www.mazesforprogrammers.com/
- loupol 4y agoAlso the blog from the book author, with visualizations and separate blog posts for several different maze generation algorithms: http://weblog.jamisbuck.org/2011/2/7/maze-generation-algorithm-recap http://weblog.jamisbuck.org/2011/2/7/maze-generation-algorit...
- mysterydip 4y agoReally neat. There was a maze generation algorithm in BASIC when I was younger that created the maze one row at a time. I couldn't wrap my head around how it was possible to make a maze like that. Searched for it recently and found Eller's algorithm: https://weblog.jamisbuck.org/2010/12/29/maze-generation-eller-s-algorithm https://weblog.jamisbuck.org/2010/12/29/maze-generation-elle...
- simon_000666 4y agothis is great, just printed out two for my kids to do, that'll keep them quiet for a bit.
- tartoran 4y agoIf you want more quiet time from your kids print out some mazes from crazy dad, they have different levels of difficulty and come in bundles. https://krazydad.com/mazes/index.php?fmt=EZ https://krazydad.com/mazes/index.php?fmt=EZ
- jhallenworld 4y agoHow about in Atari 800 BASIC with sound... https://www.youtube.com/watch?v=Yf_OPNQA1-4 https://www.youtube.com/watch?v=Yf_OPNQA1-4
- tartoran 4y agoFor whoever has kids, krazy dad makes some easy to print maze booklets with mazes to be solved. There’s a lot of other goodies on that site as well. https://krazydad.com/mazes/index.php?fmt=EZ https://krazydad.com/mazes/index.php?fmt=EZ
- manimino 4y agoHere's a Python one, with a UI, cli, and a lovely 3blue1brown visualization in the readme. https://github.com/will2dye4/labyrinth https://github.com/will2dye4/labyrinth
- lakomen 4y agoThat was a-mazing SCNR