Create a 2d circular maze
How can I create a 2d procedurally generated circular maze like the following picture:
Any maze generation algorithm, that only relies on a set of nodes (pretty much all) will work. Instead of creating a grid, where each grid point is a node and they connect to their neighbours, you need to generate them in the circular shape.
So, first of all, the center is a node. Let’s say the next layer has 6 nodes and the middle connects to all of them. To make sure the maze stays consistent, each layer (apart from the second) should have twice as much nodes, as the one before, because you need one neighbour for every node in the last layer and you need to put one extra node between them, so that the maze becomes more detailed the farther you go from the center.
Pseudo code for this:
nodes is an empty set of nodes put central node in nodes put the second layer's nodes in nodes connect the first and second layer let currentLayerCount be 12 for every layer for i from 0 to currentLayerCount create a node with a position x: cos(2*pi / currentLayerCount) * layerId y: sin(2*pi / currentLayerCount) * layerId put node in nodes if i is divisible by 2 connect the node to the neigbouring nodes in the same and last layer else only connect the node to the neighbouring nodes in the same layer end if end for multiply currentLayerCount by 2 end for
- Database Administration Tutorials
- Programming Tutorials & IT News
- Linux & DevOps World
- Entertainment & General News
- Games & eSport