Maze generation


Hello, everyone.

Last two weeks we were busy developing main feature of our small game -- maze generation. Task was pretty simple: generate random mazes with several rules and full it with specific node types (security, core, vulnerability etc.) based on their position in maze.

We thought that unity could help us with this kind of generation and it was a mistake. Luckily, there're a lot of mathematicians in gamedev world. Thanks to https://www.redblobgames.com/grids/hexagons/ we found all needed info for hexagonal grid calculations. Based on this we create a model for hexes and simple class for nodes to make sure they will always attach to proper position on screen.

Next part was a bit of challenge. All maze algorithms based on square grids and we use hexagonal one. Spending day on researching all possibilities we chose Prim's algorithm, but this was only a first step. We still needs to place nodes based on some rules, for instance, core node (level objective) should always be placed in `maxSteps-2` maze node and security nodes should block some other nodes and so on. Here we use Breadth-first search algorithm, which allows us fill our maze with nodes within two bypasses, which was great and fast.

It was interesting and extremely productive sprint for us. And here're some screenshots of generation results.

Big thanks to my friend @inca (https://github.com/inca) for help with this task and tons of consultations.

Hope your weeks were great as well, guys. 

See you in next post ^_^/

Get Entry point

Leave a comment

Log in with itch.io to leave a comment.