Home Upgrade Search Memberlist Extras Hacker Tools Award Goals Help Wiki Contact

.NET 

Maze Generator

[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)
Nice

Once you have a maze, you can then have the program solve it too... 👍
https://channel9.msdn.com/coding4fun/blo...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/
Woah nice job, I've thought of attempting to do this a few times before but never got around to it, good job.
That's actually pretty sick dude, nice work :)
[Image: mE03.png]
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.
Yo that's pretty fucking cool man. I can now go through mazes all day to entertain myself for hours!
Now make the solver, I'm curious on how you would do that
[Image: HJdK32K_x]
lensert.com is the new screenshot utility, try it out now!
OSX & WINDOWS

(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


Possibly Related Threads...
Thread / Author Replies Views Last Post
[Python] by xZalurexMay 29, 2021 05:24 PM 2 147 May 29, 2021 05:24 PM
Last Post: xZalurex
[.NET] by H4x10rOct 23, 2019 11:33 PM 4 319 Oct 23, 2019 11:33 PM
Last Post: H4x10r
[C] by IrritiableMay 8, 2019 10:56 AM 6 540 May 8, 2019 10:56 AM
Last Post: MaximumPain