3D Matrix Game

Introduction

I thought about building some kind of a game and came up with this. (I know, it is not very original.)

Create a 3D matrix of partially connected nodes. The user must find their way from a starting node to an end node.

Note: Part of the difficulty of the game is keeping track of where you are in a large matrix. (where have you been, where you are going, where is the end node, ...)

The matrix is a cube1 made up of nodes. Each node has x,y,z coordinates in the matrix (cube).

The player moves from the starting node to connected adjacent nodes until they reach the end node. Not all adjacent nodes are connected and not all connections allow two way travel. (You may not be able to backup if you make a mistake.)

There are also a few ( zero or more) wormholes. Wormholes allow one way travel to a another node but the destination node is unknown to the player. It is possible to get trapped in a node that has no exit. A wormhole, However, can speed up travel through the matrix. (Do you feel lucky?)

1A cube is a box-shaped object that has six identical square faces.

How to Play

At the beginning of the game the player is at the start node. They are presented a menu to select a movement option or display other information2.

2One of the menu options shows the player what movement is allowed from the player's current node.

The player uses the menu to move to an adjacent node or jump through a wormhole.

The player moves from node to node until they reach the end node or get trapped in a node or gives up.

The movement options are:

MovementAxisDirectionDescription
upY+Ymove to an adjacent node, if allowed
downY-Ymove to an adjacent node, if allowed
forwardZ+Zmove to an adjacent node, if allowed
backwardZ-Zmove to an adjacent node, if allowed
leftX-Xmove to an adjacent node, if allowed
rightX+Xmove to an adjacent node, if allowed
wormhole
jump
??jump to an unknown node, if allowed

Note: Nodes are uniquely defined by their x,y,z coordinates within the Matrix. Although currently you can not see the matrix, you can imagine it with 0,0,0 in the lower left corner of the screen; +Y is up, +X is right, and +Z coming out of the screen.

Main Menu

=================================================== Find A Path Thru The 3D Matrix =================================================== Option Description ------ ------------------------------------------- 1 move forward ( z axis, z=z+1 ) 2 move backward ( z axis, z=z-1 ) 3 move up ( y axis, y=y+1 ) 4 move down ( y axis, y=y-1 ) 5 move left ( x axis, x=x-1 ) 6 move right ( x axis, x=x+1 ) 7 wormhole jump 9 display current node info 20 load matrix definition file 30 go to start node 40 display matrix info 90 create new random matrix 98 debug menu 99 exit program Select option:

Current Node's Information Display

----------------------------------------------- Current Node Navigation Information ----------------------------------------------- Coords: x=4,y=1,z=0 Available Move Directions: down forward Blocked Move Directions: up backward left right Wormhole: not available Press enter to continue

My Coding Philosophy

a. An interpreter like Python is not generally usable for real time or near real time. You should be using a more appropriate language (c, assembler, ...). Using Python says that execution time is not an urgent requirement. (A little slower is OK.)

b. Code that is readable and maintainable should be simple and well formatted. Esoteric and obscure code constructs should be avoided. Simple straight forward code is best. (This is not a contest to demonstrate what a cool coder you are.)

c. Therefore, simple not complex and straight forward not convoluted.

d. Your code will always have bugs. Have a code walk through. Walking through your code with a fresh pair of eyes will find many problems before the program is released. (Try to set your ego aside. You are not perfect.)

Design Notes

1. This all started because I was trying think up a way to build a random path through a 3D matrix of nodes from a start node to an end node. (At this time I don't know if what I have in mind will work. We will just have to see.)

2. Currently the python code is a framework to test moving through the matrix. (Next is to add a path building algorithm. This is the hard part.)

3. Someday I hope to add displaying the matrix. (tk?) (Rotate the matrix?) (Zoom in and out?) (Show connections?)

4. The start node has a Z coordinate of zero and randomly selected X and Y.
The end node has a Z coordinate of the maximum allow within the matrix and randomly selected X and Y.

5. Matrix x,y,z coordinates are integers (zero (0) to matrix_edge_length-1).

Coordinate Systems

The most common way of describing 3D objects (the game's matrix) is through the use of a 3D Cartesian coordinate system. The left handed coordinate system has Y increasing going up, X increasing going right, and Z increasing going into the screen. The right handed system has Z increasing in the opposite direction (coming out of the screen).

Possible Future Modifications

1. Create a GUI for the matrix game.

2. Add multiple wormholes from a single node.

3. Add traps. For example:

4. Add an elapsed timer? (How fast can you find the path thru the matrix?)

5. Add a node movement timer? (A user must move before the current node's timer expires.)

FYI Links

A* Pathfinding Visualization Tutorial - Python A* Path Finding Tutorial (YouTube)