4D Maze - (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. 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
Ex:
java -jar Maze4D.java 5
This initializes a 5×5x5×5 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
Ex:
java -jar Maze4D.java 5 5 3 2
This initializes a 5×5x3×2 maze. Start = (0,0,0,0), Finish = (5,5,3,2)
5×5x3×2 = 150 rooms.
java -jar Maze4D.java
creates a default maze of dimensions 4×4x4×4
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 10×10x10×10, 10000 rooms, will likely cause an error caused by using too much memory. besides, a 10000 room is very, very complicated, especially in 4D.










Good writing. Keep up the good work. I just added your RSS feed my Google News Reader..
Matt Hanson
Thanks alot! I’ll try to keep making stuff.
You also have some very useful blog articles.
Thank you!
Showed my brother this. The 4D Rubiks Cube site is awsome as well.