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

.NET 

Maze Generator Revamped [Backtrack Maze Algorithm & A* Pathfinding]

[Image: xIRp0xJ.gif][Image: H0Bgtg0.gif]
[Image: BoTgV26.png][Image: YiyeHLO.png]

In the past i made a maze generator that wasn't quit the result i always wanted but since i'm doing a lot of path finding projects i started to make
another maze generator from the ground up that supports a node framework that makes life easy for path finding code to adapt and implement.

This version performs quit a bit faster and has nodes that have a somewhat richer functions set attached to them.

Setting up

Code
Dim maze = New Maze.Generator(NodesX, NodesY, Bounds)

Making new mazes

Code
Maze.Randomize()


Functions
  • All Nodes have their own pencils (color, size, style)
  • All Nodes have an 'Access' field that can be set (Start, End, Solid, Open, etc)
  • All nodes have fields that can identify them by row, column, index

From each node you can test if the next node is accessible, ie no walls.
Code
Public Function IsAccessible(target As Node) As Boolean

You can also test if a position is within a certain node
Code
Public Function IsInside(point As Point) As Boolean

Fetch a neighbour node from either index or direction (north, south, etc)
Code
Public Function GetNeighbourAt(direction As Direction) As Node
Public Function GetNeighbourAt(index As Integer) As Node

Fetch all neighbours
Code
Public Function GetNeighbours() As Node()

Test if the node has a neighbour on given parameter
Code
Public Function HasNeighbourAt(direction As Direction) As Boolean
Public Function HasNeighbourAt(index As Integer) As Boolean

Get the pixel distance between two nodes
Code
Public Function GetDistance(target As Node) As Double

Get the center of a node
Code
Public ReadOnly Property Center As Point

Small example

Code
Dim start As Node = Me.Maze.Nodes(0, 0)

If (start.HasNeighbourAt(Direction.East)) Then
     If (start.IsAccessible(start.GetNeighbourAt(Direction.East))) Then
            '//...we can move east
     End If
End If


Update: Added a build-in solver, example is included inside the source files

Github: https://github.com/TheBarret/Maze-Generator-Framework

have fun!
- B
Hey thank you mate I will generate few one and print them for my children.

You are my idol bro

✌
This is pretty cool, I remember seeing someone else post a maze generating algorithm here a long while back but I can't remember who it was. :)

Why did you use a scrollbar for the tracker though? https://msdn.microsoft.com/en-us/library...2147217396
Getting Started: C/C++
[C/C++/.NET/x86 ASM - Automation Programmer]
(Feb 8, 2018 12:22 AM)0xDEAD10CC Wrote:  This is pretty cool, I remember seeing someone else post a maze generating algorithm here a long while back but I can't remember who it was. :)

Why did you use a scrollbar for the tracker though? https://msdn.microsoft.com/en-us/library...2147217396

op https://hackforums.net/showthread.php?tid=5546640
[Image: bitcoin.png] Be Nice For Once 15hVUVz7xA4kazHdk2BuErENGCskVwjYXP
(Feb 8, 2018 03:14 AM)HFDone Wrote:  op https://hackforums.net/showthread.php?tid=5546640

No I mean back in probably 2011. I've been on this forum a long time.
Getting Started: C/C++
[C/C++/.NET/x86 ASM - Automation Programmer]
Updated the project with an A* solver build-in.

[Image: dRmLrlo.png][Image: RyKnNDT.png]
Woah this looks pretty cool too! Love how it shows the solution instantly when it generates the maze.


Possibly Related Threads...
Thread / Author Replies Views Last Post
[C] by SkyflixMar 8, 2022 03:35 PM 8 213 Mar 8, 2022 03:35 PM
Last Post: MavenGradle
[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