	X-BASED CUBES
	=============	Cubes X widget, V4.10


    It has been tested on the following platforms:

	HP 3xx & 700		HP-UX 9.0x	X11R5
	Sun4, SPARC		SunOS 4.1.3	X11R4
	Sun4, SPARC		SunOS 2.3	X11R5
	PC, 486 (*)		Linux 1.0.9	X11R5

    *	Keypad 5 key may not work, in which case, try it with the
	Num-Lock on

    If yours is not in this list, please let me know -- thanks. The
    most updated source could be found on ftp.x.org under
    /contrib/games/puzzles.

HOW TO BUILD?

    It should be easy. Edit the Imakefile (or Makefile.std, see below)
    for appropriate settings of variable SCOREFILE, RANDOM, then do:
	xmkmf
	make
	xcubes

    If that does not work then:
	mv Imakefile Imakefile.r5
	sed 's/^XCOMM/\/\*\*\/#/' > Imakefile < Imakefile.r5
	xmkmf
	make
	xcubes

    Note: if you don't have 'xmkmf' or the "Makefile" it generates
    doesn't work well, edit Makefile.std for appropriate settings for
    XINCLUDEPATH and XLIBPATH, then try:
	make -f Makefile.std

    You should have Cubes.ad copied to $(HOME)/Cubes or 
    /usr/lib/X11/app-defaults/Cubes to run, especially if the background
    is similar to one of the faces. Edit this file for your preferences.
    You might want to move xcubes into /usr/bin/X11 (or wherever your
    X binaries are).
    You might also want to move xcubes.man to /usr/man/man6/xcubes.6

ANYTHING SPECIAL IN USING?

    Click on the left mouse button to move brick (but not on space or a
      tile that is not in line with space).
      One must double click on the middle mouse button if the puzzle is
      being worked on.
    Click on the right mouse button if you want to randomize Cubes.
      Also 'R' or 'r' does the same thing.  One must double click on
      the right mouse button if the puzzle is being worked on.
    'S' or 's' to auto-solve.  Unfortunately, its unimplemented.
    'U' or 'u' to undo last move.
    'E' or 'e' to enter saved puzzle.
    'W' or 'w' to write or save a puzzle.
    'Q', 'q', or Control-C to kill program.

    Key pad is defined for Cubes as:
        /

        8 
        ^
    4 < 5 > 6
        v
        2

    Bricks can also be moved by the keypad,
                KP_DIVIDE=>OUT
    		KP_8=>TOP
    KP=>LEFT	KP_5=>IN	KP=>RIGHT
    		KP_2=>BOTTOM

    'I', 'i', and 'O', 'o' also work for in and out.
    Notice one can move more than one brick at a time by clicking on the
    brick farthest from the space but in line with the space. Since you
    only have a 2-D screen the next level down is either the box to the
    right of the current box or the bottom of the current box.

    The control key allows you to change the complexity of xcubes.  Hold
    down control key and use the keypad.
 
    Try resizing xcubes. Notice the puzzle resizes to take advantage of
    the "room" available.

    The title is in the following format:
	xcubes: <int>x<int>x<int> @ (<Number of moves>/\
		{<Record number of moves>|NEVER|PRACTICE}) - <Comment>
    <int>x<int>x<int>: row by column by stack.
    {<Record...}: puzzle is either in practice mode or record mode
       In record mode, if there is no record of the current puzzle, it
       displays "NEVER".

    I know the X11 "puzzle" shows the piece sliding, has a auto-solver,
    and a graphical image, but this program completes a theme with
    xtriangles and xhexagons. This program can be generalized to do a
    tesseract the puzzle gets no harder than the 2-D puzzle except its
    more tedious.
 
    Keep in mind that Cubes is a widget that can be simply stuck in
    other X programs. (If you find a use for this, let me know).

    Refer to the man page for detailed command line options.

    If you want further information on puzzles, I'll be glad :-) to send
    it to you.

SAVE FORMAT

    The format is not standard.  The reason is that this is simple to
    produce and I do not know what the standard is.  The format will
    probably change to become more readable.

    size_x: number of bricks in a row
    size_y: number of bricks in a column
    size_z: number of bricks in a stack
    moves: 0-MAXINT

    starting position: array where 0 is the empty space

    This is then followed by the moves
    move #: direction
    Direction is represented as 0 up, 1 right, 2 down, 3 left, 4 in, and 5
      out.

    Caution: the program may crash on corrupted input.
     
MATHEMATICAL BASIS
 
    Assuming it is a box of i columns, j rows, and k stacks and the
    numbering starts from 1.
       Corner 1-> 1
              2-> i
              3-> i*j-i+1
              4-> i*j
              5-> i*j*k-i*j+1
              6-> i*j*k-i*j+i
              7-> i*j*k-i+1
              8-> i*j*k
       Center -> i%2 =>
              0: None
              1: ((i+1)/2)^3
 
       Max_Width -> i units
       Max_Height -> j units
       Max_Depth -> k units
 
       Start -> x=y=z=0
       Next -> n%i =>
              0: x= 0 units; y+= 1 unit
                  if (y == j)
                     {y = 0 units; z+= 1 unit;}
              default: x+= 1 unit
 
       Same row? -> (m-1) / i == (n-1) / i
       Same column? -> ((m-1) % i == (n-1) % i) &&
                        ((m-1) / (i*j) == (n-1) / (i*j))
       Same stack? -> (m-1) % (i*j) == (n-1) % (i*j)
 
FOUND A BUG?

    Send bugs reports and fixes to the author. For bugs, please include
    as much information as to their location as possible, since I may not
    have the resources to duplicate the them.

	David Albert Bagley,	bagleyd@source.asset.com

HISTORY

   [May 16, 95] V4.10: Warnings removed from Sun's cc and lint and now
		include a random number generator.
   [Mar 13, 95]	V4.4: Removed lint warnings and added a VMS make.com .
   [Nov 11, 94]	V4.3: Conservative guess for random number generator.
   [Oct 25, 94]	V4.2: Now allows undos, saves, and recalls.
   [Jun 28, 94]	V4.1: Can accommodate a auto-solver.
   [Jun 07, 94]	V4.0: Xt version.
		I got some good ideas from oclock.
   [Apr 01, 93]	V3.0: Motif version.
		I got some good ideas from Douglas A. Young's
		book: "The X Window System Programming and Applications
		with Xt OSF/Motif Edition", particularly his dial widget.
		I got some good ideas on presentation from Q. Zhao's
		tetris.
   [Dec 19, 91]	V2.0: XView version.
   [Aug 01, 91]	V1.0: SunView version.
