Last edited December 5, 2013 by Vassil Mladenov (mladeno2@illinois.edu)

HyperSnake: The Classic Game in Four Dimensions

Table of Contents

1. Abstract
2. Overview
3. Updates

Abstract

The purpose of this project was present the concept of four-dimensional geometry in an interesting and inventive way by building a four-dimensional rendition of the classic Snake game using Python and OpenGL.

Overview

For those who have never heard of the classic video game Snake, this is a simple Flash version of the game available freely on the internet. It is controlled with the arrow keys, and the purpose is to eat as many apples as possible without intersecting the snake's tail. Each apple causes the snake to grow one unit. Different versions of the game place different restrictions on the boundaries of the game space, the most common of which is causing the game to end when the snake collides with the edge of its space.

My project, as stated in the abstract, was to expand this into four dimensions. To run the game, please run the command

python finalProject.pyfrom the folder in which HyperSnake resides from a system with Python installed. The following screenshots are all taken from a machine running Mac OS X 10.9. The screen we see when we first start HyperSnake is shown below. Click the images to enlarge them.

The initial viewpoint is pointing down the z axis. In other words, the x axis points to the right, the y axis points up, and the z axis is oriented out of the screen. Pressing the (I) key several times leads us to the following image.

Strange! We are told that pressing (I) will result in a 4D rotation, but the game space appears to be a simple cube rotating in 3D! There is more to this than meets the eye. Let's reset the game. This time, once the head's x coordinate reaches 0.0 again, press (E) to make the snake go in the positive z direction - or out of the screen. Now press (I) several times to do that "3D" rotation trick that we saw before. That should let us see the side of the snake, right?

Where did the snake go? Move the mouse to find out.

There it is! However, what we thought was a simple cube was actually a tesseract, or a four-dimensional hypercube, the four-dimensional analog of a cube. Each body element of the snake and the apple are also hypercubes. Telling the snake to go in a certain direction may cause it instead to start becoming larger or smaller. Try using 4D rotations to straighten it out. Also, notice how the axes that are not in the rotating plane maintain their orientation. We are used to seeing only one axis fixed when an object rotates in three dimensions. Now, two axes are fixed. The important thing to understand is that we are not actually seeing a four-dimensional wireframe, merely its three-dimensional shadow caused by a "flashlight" that I have set at position w = 10 pointing in the negative w direction. For more commentary about the nature of simple four-dimensional geometry, please refer to the documentation. The following is an animation of HyperSnake in action.

Updates

12/5/13 Final update to the website before it goes live.
12/2/13 The project has been modified to improve visibility of axes and to comply with illiMath conventions.
11/25/13 The project is now complete. I may have to do a few formatting tweaks given the screen on which I will be presenting. I will spend the remaining time working on my documentation.
11/18/13 A lot has happened in 6 days. The snake portion of my RTICA is more or less operational. Modular movement, timer-dictated advances, apples, and the playing field still need to be implemented. What I have now is like an engine.
11/12/13 I am currently developing functions in Python for rotation in four dimensions and for a stereographic projection from four dimensions down to three dimensions.
10/06/13 Website is operational, beginning research into Python+OpenGL and four dimensional projection.