4D Maze Generation - Java

algorithm java

This is a simple implementation of a 4D maze written in Java. As of now it is entirely text based however, a simple GUI is currently under development. It should be useful to modify as needed. The algorithm used to generate the map is quite simple and always generates a perfect maze.

  1. Randomly choose a starting room.
  2. Add all surrounding rooms that have not been visited, or to a list.
  3. While there are rooms in the list randomly select one.
  4. Set the room to visited, and start again from step 2 using the current room.

Note: This implementation uses recursion to do this. This code has not been thoroughly checked for possible bugs (namely Stack Overflows). The Jar file can be downloaded here: Maze4D.jar

Run

Example 1

java -jar Maze4D.java dimXYZU
java -jar Maze4D.java 5

This initializes a 5x5x5x5 maze. Start = (0,0,0,0), Finish = (5,5,5,5) that's 5^4 rooms, 625 rooms, that's a lot of rooms to navigate in 4D. :)

Example 2

java -jar Maze4D.java dimX dimY dimZ dimU
java -jar Maze4D.java 5 5 3 2

This initializes a 5x5x3x2 maze. Start = (0,0,0,0), Finish = (5,5,3,2) 5x5x3x2 = 150 rooms.

Example 3

java -jar Maze4D.java

creates a default maze of dimensions 4x4x4x4

Commands

To move in the positive X direction type "x", to move in the negative X direction type "-x".

All the commands are: x,-x,y,-y,z,-z,u,-u

4D maze java



comments powered by Disqus