Algorithms, Data Structures, Graphics, Procedural Generation, RNG
Josh Cooper
 Pub. Date: 2016.03.24


hypermaze demo

An Introduction


What is a hypermaze? It is any maze which exists in a higher dimension. This project is a hypermaze because the data can be described as four dimensional, and the maze is rendered using only two. Two dimensions describe the connections between rooms in the maze, and the other two describe how to express that information. It may, in fact, be more deserving of a name such as Wormhole-Maze, but that sounds quite awful.

This project was inspired by my interest in theoretical physics. I designed this not to create a game, but to mere prototype an idea. Though, with the project now finished mostly~ I am sure a game could be designed using this prototype.

Description


This project generates a maze, and then allows the user to navigate through the maze one room or corridor at a time.

The maze is generated by expanding from a given node, so it needs to be given a root node. The root node is put onto a double ended queue just before the algorithm’s main loop. Inside the loop the algorithm takes the previous generation of nodes out of the queue, one at a time, and expands from them.

The algorithm has a particular number of node generations it must complete; this number is acquired as a function parameter. Although every node is looked at by the algorithm, not every node will be expanded from. Even when a node is expanded from, it won’t always create a new node to, in turn, be expanded from. All nodes have a possibility of looping back to themselves or other existing nodes. Furthermore, every expansion can result in several new connections to the node being expanded from. A node may end up with anywhere between 1 and, feasibly as high as, 30 connections to other nodes; only 7 or less can be children of the node itself, speaking from a tree graph perspective.

I used the generation algorithm as an excuse to pull out C++11’s random library, and much of what it offered. I made use of three types of random number distributions: piecewise_linear_distribution; bernoulli_distribution; uniform_int_distribution. In total, I had 6 number distributions.

Objectives


  • Test how well a hypermaze could be navigated. With only one new space presented at a time, opposed to using a line of sight feature.
  • Play around with procedural generation. Tweak variables, and number distributions.
  • Implement a Tile Map capable of expanding the boundaries of the world it represents.

Highlights


Successes

  • Fulfilled the main goal of the prototype. The hypermaze can be navigated without technical difficulties.
  • Tackled the Tile Map requirements successfully; albeit with the aid of the GameDev.net community. The maze doesn’t have width by height so a regular tile map capable of loading a width by height map wasn’t enough. The tile map needed to expand as the maze was explored, and that’s what it does.

Challenges

  • Debugging. The generation algorithm won’t tell you the hypermaze is broken, you’ve got to try navigating it to figure that out.
  • Translating coordinates from the hypermaze “world” to individual terrains to tile map chunks. That may or may not be the exact order of most translations, but it gets the idea across. Three coordinate spaces is a bother to say the least.

Results


The prototype turned out well. I wish I could have resolved every bug I discovered, but it wasn’t meant to work 100%. It was meant to show that a hypermaze could be successfully rendered in a, at least in part, user-friendly way. If you don’t know what I mean, just google images “hypermaze”. Thus capable of successfully being implemented in a game, perhaps even a 3d adventure rpg.

One day I may even return to it and implement it into a game myself.