Hack Forums
[.NET] Maze Generator - Printable Version

+- Hack Forums (https://hackforums.net)
+-- Forum: Tech (https://hackforums.net/forumdisplay.php?fid=444)
+--- Forum: Coding (https://hackforums.net/forumdisplay.php?fid=151)
+---- Forum: Software Development (https://hackforums.net/forumdisplay.php?fid=118)
+---- Thread: [.NET] Maze Generator (/showthread.php?tid=5546640)



Maze Generator - Barret - Feb 8, 2017

[Image: k85RqWu.png][Image: AIJmB77.png][Image: NOZwdZG.png]

Very small and compact maze generator class that works best with asynch thread and a callback.
Let me state that i don't own nor thought of this, it is public domain. Credits goes to a Phd teacher in a university from Polen.

How to use

[Image: J0uEpV7.png]

Class constructor
Code
Maze.Generator(Size, Color, PenSize)
- Size Is the final bitmap size it generates
- Color, Pen size Well that speaks for itself...

Maze.Generator.StartAsynch()
Code
Maze.Generator(Size, Color, PenSize).StartAsync(GridSize, Seed, Complexity, Delegate(Callback))
- Gridsize Is how large the maze is going to be, i suggest you keep this lower then 256x256 (even my 8-core will bitch slap me for this size)
- Seed Is for the randomizer
- Complexity This determines how complex it is going to be, values between 0~64, small values generates an easy maze
- Delegate Where to call back when the generate is done


The generator source
Spoiler (Click to View)

For those that wonder how the 128x128 grid would look like, here you go:
[Image: nNjOTAm.png]
(This was done in 201.7996 msecs)


* - Zilog80 - Feb 8, 2017

Nice

Once you have a maze, you can then have the program solve it too... 👍
https://channel9.msdn.com/coding4fun/blog/Getting-lost-and-found-with-the-C-Maze-Generator-and-Solver

Bonus track #1: a lot info about mazes: http://www.astrolog.org/labyrnth/algrithm.htm
Bonus track #2: 'Visual' Depth First Search algorithm: http://www.migapro.com/depth-first-search/


* - VmX5 - Feb 8, 2017

Woah nice job, I've thought of attempting to do this a few times before but never got around to it, good job.


* - █─█ █▄█ █▀▄▀█ - Feb 8, 2017

That's actually pretty sick dude, nice work :)


* - Ninja - Feb 8, 2017

This is awesome. It pleases my eyes.
But is it me or is there a lot of repetition in the patterns? Like, I see a lot of lines hook up, but never hook down.


* - MeltyNet - Feb 9, 2017

Yo that's pretty fucking cool man. I can now go through mazes all day to entertain myself for hours!


* - marvinn - Feb 9, 2017

Now make the solver, I'm curious on how you would do that


* - Barret - Feb 9, 2017

(Feb 9, 2017 02:44 AM)marvinn Wrote:  Now make the solver, I'm curious on how you would do that

There was a solver but that code required some serious optimizing if i was to port it, i had to tune this code as well, teacher was smart about the algorithm but did not use the right design for certain elements.

(Feb 8, 2017 10:54 PM)Ninja Wrote:  This is awesome. It pleases my eyes.
But is it me or is there a lot of repetition in the patterns? Like, I see a lot of lines hook up, but never hook down.

The idea behind it is that all cells start closed (squares) and the pathways are randomly walked and by doing so opening the squares and creating a new road, the approach from that teacher was using headings, going north, west etc etc