4D Maze - (Java)

Posted on by Kenny Cason
tags = [ 4d, generation, java, maze ]

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. Either way, this simple implementation should be useful to modify and/or build off of. 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 their 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: the Java version used in this implementation uses recursion to do this. This code has not been thoroughly checked for possible bugs, and I am sure there is a more efficient method to write a 4D maze. But, at the very least, it is flexible and each room of the maze is of class type Room4D and should be easy to modify. The Jar file can be downloaded here: Maze4D.jar

To run from the command line
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. :)

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.

java -jar Maze4D.java

creates a default maze of dimensions 4x4x4x4

Note: be careful not to load a 4D maze that’s too big or Java will run out of memory, depending on your Java settings. For example creating a room that is 10x10x10x10, 10000 rooms, will likely cause an error caused by using too much memory. besides, a 10000 room is very, very complicated, especially in 4D.

4D maze java





comments powered by Disqus