Hacker News new | past | comments | ask | show | jobs | submit login
Show HN: Maze Generation Visualization (github.com/pakastin)
70 points by pkstn on July 9, 2022 | hide | past | favorite | 18 comments



Or 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.


> 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


Clang 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);


Really 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-elle...


My three different versions I did long time ago in Perl: https://github.com/xa-bi/mazes


Cool!


If you're into maxes and coding you should check out: http://www.mazesforprogrammers.com/


Also 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-algorit...


For 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


Here's a Python one, with a UI, cli, and a lovely 3blue1brown visualization in the readme.

https://github.com/will2dye4/labyrinth


How about in Atari 800 BASIC with sound...

https://www.youtube.com/watch?v=Yf_OPNQA1-4


This is really cool. Reminds me of my early days dabbling in basic


Haha, a mazing!


I could watch this for hours. :)


Haha, me too :D


That was a-mazing SCNR


this is great, just printed out two for my kids to do, that'll keep them quiet for a bit.


If 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




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: