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.












![rotXY = delim{[}{matrix{4}{4}{{cos(theta)} {sin(theta)} 0 0 {-sin(theta)} {cos(theta)} 0 0 0 0 1 0 0 0 0 1}}{]} rotXY = delim{[}{matrix{4}{4}{{cos(theta)} {sin(theta)} 0 0 {-sin(theta)} {cos(theta)} 0 0 0 0 1 0 0 0 0 1}}{]}](http://ken-soft.com/wp-content/plugins/wpmathpub/phpmathpublisher/img/math_941.5_386f86decb4f40b917dfd6db830318eb.png)
![rotYZ = delim{[}{matrix{4}{4}{1 0 0 0 0 {cos(theta)} {sin(theta)} 0 0 {-sin(theta)} {cos(theta)} 0 0 0 0 1}}{]} rotYZ = delim{[}{matrix{4}{4}{1 0 0 0 0 {cos(theta)} {sin(theta)} 0 0 {-sin(theta)} {cos(theta)} 0 0 0 0 1}}{]}](http://ken-soft.com/wp-content/plugins/wpmathpub/phpmathpublisher/img/math_941.5_d339828f569aa5fef53964595e60e7dc.png)
![rotXZ = delim{[}{matrix{4}{4}{{cos(theta)} 0 {-sin(theta)} 0 0 1 0 0 {sin(theta)} 0 {cos(theta)} 0 0 0 0 1}}{]} rotXZ = delim{[}{matrix{4}{4}{{cos(theta)} 0 {-sin(theta)} 0 0 1 0 0 {sin(theta)} 0 {cos(theta)} 0 0 0 0 1}}{]}](http://ken-soft.com/wp-content/plugins/wpmathpub/phpmathpublisher/img/math_941.5_68fa0611192405b45f28bdf0af541d03.png)
![rotXU = delim{[}{matrix{4}{4}{{cos(theta)} 0 0 {sin(theta)} 0 1 0 0 0 0 1 0 {-sin(theta)} 0 0 {cos(theta)}}}{]} rotXU = delim{[}{matrix{4}{4}{{cos(theta)} 0 0 {sin(theta)} 0 1 0 0 0 0 1 0 {-sin(theta)} 0 0 {cos(theta)}}}{]}](http://ken-soft.com/wp-content/plugins/wpmathpub/phpmathpublisher/img/math_941.5_bae5dc667d825cb897c4d017c7a422d3.png)
![rotYU = delim{[}{matrix{4}{4}{1 0 0 0 0 {cos(theta)} 0 {-sin(theta)} 0 0 1 0 0 {sin(theta)} 0 {cos(theta)}}}{]} rotYU = delim{[}{matrix{4}{4}{1 0 0 0 0 {cos(theta)} 0 {-sin(theta)} 0 0 1 0 0 {sin(theta)} 0 {cos(theta)}}}{]}](http://ken-soft.com/wp-content/plugins/wpmathpub/phpmathpublisher/img/math_941.5_ab7a54a79ef160a0aa918151d9d55ce9.png)
![rotZU = delim{[}{matrix{4}{4}{1 0 0 0 0 1 0 0 0 0 {cos(theta)} {-sin(theta)} 0 0 {sin(theta)} {cos(theta)}}}{]} rotZU = delim{[}{matrix{4}{4}{1 0 0 0 0 1 0 0 0 0 {cos(theta)} {-sin(theta)} 0 0 {sin(theta)} {cos(theta)}}}{]}](http://ken-soft.com/wp-content/plugins/wpmathpub/phpmathpublisher/img/math_941.5_75c90de6d3b518ddba1001f07fa85adf.png)



