Ken-Soft

Software and the World


4D Maze - (Java)

Posted under General Development, Java, Mathematics, Software Development by Kenny on Wednesday 14 January 2009 at 12:23 am

Bookmark and Share

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.
4D maze java

Rect4D.java

Point4D.java

Room4D.java

Maze4D.java

Share on Facebook

4D Rotation Matrix - Graph 4D

Posted under General Development, Java, Mathematics, Programming by Kenny on Thursday 8 January 2009 at 3:52 pm

Bookmark and Share

This program rotates points about the XY, YZ, XZ, XU, YU, and ZU axises. I then projects each 4D vector to the 2D canvas.
The Jar file can be downloaded here: Graph4D.jar

4D rotation matrix java 4D rotation matrix java

Before looking at the source, let’s take a look at some of the fundamental mathematics behind the software.
If you are uncomfortable with the thought of 4D matrix rotations, then I recommend reading Wikipedia, or checking out my article about 3D graphing, which can be found here. In this example, I will only show the 4D rotation matrices. Note that for each rotation matrix, 2 axises are held still while the vector is rotated around the other two axises. This may be hard to visualize at first, but It will become clear after a while.
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}}{]}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}}{]}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}}{]}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)}}}{]}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)}}}{]}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)}}}{]}

The source code can be found below as well as being bundled into the Jar file.

Transform4D.java - contains method for rotating a 4D vector

Transform4D.java

Point4D.java

Graph4D.java

Share on Facebook

Thog Problem

Posted under Learning, Logic Problems by Kenny on Thursday 8 January 2009 at 5:04 am

Bookmark and Share

Given the following combinations of shapes and colors:

The experimenter makes the following statement:

“I am thinking of one color (black or white) and one shape (square or circle). Any figure that has either the color I am thinking of, or the shape I am thinking of, but not both, is a THOG. Given that the black square is a THOG what, if anything, can you say about whether the other figures are THOGS?”

Select the THOG by clicking on one of the shapes above

Share on Facebook

Next Page »

Copyright © 2009 www.Ken-Soft.com