gnubik man page

gnubik — an interactive, graphic Magic cube program.


gnubik [window_system_options] [-hvs] [-z n[,m[,p]]] [-a m]


This is a program which displays a 3 dimensional image of a magic cube, as introduced to the world by its Hungarian inventor, Erno Rubik. The user rotates the blocks of the cube, and attempts to solve the puzzle, by moving all the blocks to their correct positions and orientations, resulting in a cube with a single colour on each face.


The user interacts with the program in the following ways:

Viewing the Cube

The viewing position may be altered using the arrow keys or by using the mouse. The left and right arrow keys rotate the cube about the vertical axis. The up and down keys rotate the cube about the horizontal axis. Holding down the shift key whilst pressing the left and right arrow keys rotates the cube about the z axis.

To rotate the cube using the mouse, hold down button 1 and move the mouse anywhere on the window. If your mouse has a scroll wheel, you can use this to rotate the cube about the z axis.

Performing Rotations

Rotations are performed using the mouse. To manipulate the cube, place the mouse cursor on a square in the cube, against the edge facing the direction you want to move, and click button 1.

The mouse cursor will indicate the direction of rotation.


The following options may be specified on the command line at invocation.

-z n,m,p
Draws a cube of size n x m x p, where n,m and p are positive. The default size is 3 x 3 x 3.
-a m
When rotating parts of the cube, show m intermediate positions. The default for this value is 2. Setting to a higher value, will give smoother animations, but will result in a slower program.
Starts with the cube already solved. By default, it starts in a random position.
Display a help message and exit.
Display version number and then exit.


The code for gnubik is written in C and Scheme. It uses the Mesa/OpenGL graphics library, and the Gtk+ library and Guile. As such, it should be easy to generate a version for any system complying with these standards.


The rendering process is slower than it could be, since display lists aren't currently used. The entire image is re-rendered, during each refresh, regardless of which components have changed their appearance.


JMD GNU Utility Documentation 01 January 2011