I thought about building some kind of a game and came up with this.
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, ...)
A 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.
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:
Movement | Axis | Direction | Description |
---|---|---|---|
up | Y | +Y | move to an adjacent node, if allowed |
down | Y | -Y | move to an adjacent node, if allowed |
forward | Z | +Z | move to an adjacent node, if allowed |
backward | Z | -Z | move to an adjacent node, if allowed |
left | X | -X | move to an adjacent node, if allowed |
right | X | +X | move 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 going into the screen.
=================================================== Find A Path Thur 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 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
The program is split into several source and documentation files. Click of the links below to see the contents.
File Name | Description |
---|---|
game_matrix.py | Main program. |
game_matrix01.py | Matrix node class definition.
Support functions to create,manipulate/access the matrix. |
game_matrix_config.py | Global variables. |
game_matrix_def_file.py | Read game matrix definition files.
Used to read "hard coded" matrix definitions for testing. |
game_matrix_gen.py | Functions to generate matrix random start node, end node and path.
(A major goal of this project.) |
game_matrix_menu.py | Game menu functions.
Crude "hand coded" menus for testing. (To be replaced eventually with a GUI.) |
game_matrix_tk.py | Functions to generate a graphical interface to the game.
(I may not end up using Tk.) (I may not end up creating a GUI.) |
game_matrix_doc.html | This documentation. |
game_matrix_doc_01.html | Matrix definition file documentation. |
game_matrix_doc_02.html | Matrix Python code examples. |
game_matrix.html
game_matrix01.html game_matrix_config.html game_matrix_def_file.html game_matrix_gen.html game_matrix_menu.html game_matrix_tk.html |
PyDoc files. (For example: pydoc -w game_matrix) |
game_matrix_01.txt
game_matrix_02.txt game_matrix_03.txt | "Hand coded" matrix definitions for testing, etc. |
game_matrix.zip | all of the files above. (may not be the latest but it will be close) |
Note: Files are created and tested one at a time and incrementally modified to eventually reach the final goal. (A crude but workable game.)
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.)
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).
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).
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.)