home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Shareware Overload
/
ShartewareOverload.cdr
/
games
/
rbcube.zip
/
RUBIK.DOC
next >
Wrap
Text File
|
1990-01-26
|
24KB
|
424 lines
R U B I K ' S C U B E
Version 1.03b
by
Calvin Culver
26 January 1990
I. Introduction.................................2
II. The Opening Screen..........................3
A. The Graphics............................3
B. The Windows.............................3
III. What to Do?................................4
A. The Main Menu...........................4
1. Solving the Cube...................4
2. Playing with the Cube..............5
3. Quitting Rubik's Cube..............5
B. The User Menu...........................5
1. Making Your Move...................5
2. Coloring the Cube..................6
3. Resetting the Cube.................7
4. Saving the Current State...........7
5. Restoring a Saved State............7
IV. Some Final Comments.........................8
V. Disclaimer, Copyright and a Thank You........9
I. Introduction
Rubik's Cube began as an extra credit undergraduate project
for an introductory Fortran programming course (anybody remember
WATFOR?) on a PDP 1170 running the Unix operating system. Ini-
tially, it was written for Rubik's Pocket Cube, a 2x2x2 version
of the Cube, and was never debugged. The compiler, which appar-
ently assembled code in a somewhat linear fashion, could not grab
enough memory to compiler the source. My instructor took my
problem to her supervisor, who in turn sent me to the department
heads, who told me to rewrite the blasted thing in Pascal. For
my trouble, I received 5 extra credit points.
Well, here I am now, more years later than I want to count,
and I finally decided to follow my superiors' advice. Here,
completely rewritten in Turbo Pascal, on an IBM XT microcomputer,
for a full-size Rubik's Cube, with plenty of memory left over
(isn't it amazing how far computers have come in ten years?) is
Rubik's Cube. In addition to actually compiling it, I have updat-
ed and enhanced the old Fortran version. What started out as
just a simple little program to solve the Cube has become a full-
blown nightmare (have YOU ever dreamed you were being chased by a
ten foot tall cube?) with a full-featured graphics presentation
(for Hercules and EGA; CGA just didn't have the resolution I
needed), the ability to allow the user to make his own moves,
take back moves, reset the cube, or set up the cube any way he
likes, and, of course, routines for allowing the computer not
only to solve the cube but to save the solution to a text file
for later review. And much more. But I'm getting ahead of
myself.
Actually, the program itself should be straight-forward
enough to require little documentation. Those of you who haven't
already abandoned me are now dismissed, if you'd like, to get
straight on to using the program. I've tried to make the user
screens as self-apparent as possible. But, for tidbits, tips and
traps, I'd suggest perusing this little tome eventually.
II. The Opening Screen
A. The Graphics
First things first: Do I, you may be wondering, have the
proper hardware to run this program, and how do I configure it if
I do? No need to worry. Rubik's Cube automatically checks for
the proper equipment when you first bring it up. If it can't
find anything it likes, it will so inform you and abort; other-
wise, it will configure itself automatically for either Hercules
or EGA (including VGA) depending on what it sees. (For those of
you who have neither Hercules nor EGA, but would like a Rubik's
Cube program nonetheless, I do have an older version available,
written to use ANSI graphics. It doesn't have all the fancy
features of the release version, but if you're interested, con-
tact me on my favorite BBS (see below).)
B. The Windows
When the program first comes up, you will see several
things. The left half of the screen is entirely given over to
the Cube itself. The first decision I had to make was how to
display all six sides of a three dimensional cube on a two dimen-
sional screen. This is the method I chose. The Cube window
displays two views of the Cube simultaneously: the upper view
looks down at the Cube from the front, showing the top, front and
right faces; the lower view looks up at the Cube from the back,
showing the posterior, bottom and left faces. Both views are
updated automatically as moves are accomplished.
The right half of the screen is divided between two windows.
The upper right quadrant contains the Menu window, wherein the
program displays all options currently available. In the lower
right you will find the Message window, where Rubik's Cube dia-
logues with you, asking you further questions, and informing you
of the status of certain things.
III. What to Do?
A. The Main Menu
Initially, the Menu window contains the Main Menu, with two
choices available. The first choice is '<A> Computer solves the
cube'. The second choice is '<B> User plays with the cube'.
1. Solving the Cube
Selecting <A> causes Rubik's Cube to examine the Cube to see
if it is solvable (not every cube state is solvable; for those
who are interested, a solved state can only be reached from a
small portion of the several quintillion possible combinations of
colors. It all involves a lot of higher mathematics. If you'd
like to know more, Scientific American had a fascinating article
on the Cube back in late 1980 or early 1981, including the
mathematics of 'cubology').
If the current state of the Cube is not soluble, Rubik's
Cube displays an appropriate message in the Message window and
aborts the attempt. Otherwise, you will be prompted as to wheth-
er you'd like the steps saved to a text file and, if so, what the
name of the file should be. Rubik's Cube then proceeds to solve
the Cube.
I should pause here to describe the solution file you'll get
if you elect to save the solution to disk. This file will have
whatever name you decide to give it, with an extension of '.SOL'.
The steps in the solution are given in (hopefully) pretty
straightforward language, like 'Turn front face clockwise' or
'Turn bottom face half'. The moves themselves are described as
if you were looking directly at that particular face of the Cube,
and consist of a quarter rotation (90 degrees) of the face in the
described direction (or a 180 degree rotation if doing a half
turn), but the assignation of the names of the faces depends on
your not actually turning the Cube over to look at that face.
What I mean by that is this: always keep the top face on
top, the right face on the right, and so forth. Otherwise,
you'll quite probably get lost very quickly. When you want to
execute a counterclockwise turn of the front face, simply turn
the front face one quarter turn counterclockwise. On the other
hand, a counterclockwise rotation of the posterior face will
look, from the front, as if it were turning in the opposite
direction (if you were to turn the Cube around so you were look-
ing straight at the posterior face you would see that it was,
indeed, a counterclockwise rotation). Similarly, a counterclock-
wise rotation of the right face will cause that side of the Cube
to rotate toward you (assuming you're keeping the front face in
the front like you're supposed to be doing), whereas it would
take a clockwise rotation of the left face to rotate it toward
you. And a clockwise rotation of the top face would rotate it
clockwise as if you were looking straight down on the Cube from
above, while a clockwise rotation of the bottom face would appear
to be clockwise only if you were looking straight up at it from
underneath. And it doesn't matter, of course, which way you turn
the face when you're doing a half -- or 180 degree -- turn.
Was all that too confusing, or are you all smarter than I'm
giving you credit for?
2. Playing with the Cube
The second choice on the Main Menu is '<B> User plays with
the cube'. Selecting this option opens up to you a whole new
world of possibilities, leading straight on into the User Menu
which I will describe more fully in the next section.
3. Quitting Rubik's Cube
There is actually a third choice available from the Main
Menu, as well. To exit the program entirely back to DOS, just
press the Escape key (Esc will back you out of any menu to the
previous level).
B. The User Menu
The User Menu itself contains several options, as follows:
<A> Make moves
<B> Set up the cube yourself
<C> Reset cube to original state
<D> Save current state
<E> Restore a saved state
1. Making your move
The first option, 'Make moves', takes you to yet another
menu, called the Moves Menu. Here you, the user, can make your
own moves, using the arrow keys on your keypad to turn the var-
ious faces of the Cube. To turn the left face, for example, just
press the left arrow. The up arrow turns the top face, the down
arrow the bottom face, Home turns the front face, and End the
posterior face. It must be kept in mind that all moves consist
of clockwise quarter turns only. Therefore, if you want to
rotate a face 180 degrees, you must rotate it two quarter turns.
A counterclockwise quarter rotation is accomplished with three
clockwise rotations. Thus, for example, to turn the right face
one quarter turn counterclockwise, press the right arrow three
times.
In addition, Rubik's Cube will remember all the previous
moves you made, up to 100 moves, allowing you to take back as
many moves as you'd like. To take back a move, just press the
Delete key. To take back the last four moves you made, press Del
four times.
2. Coloring the Cube
The second option on the User's Menu is '<B> Set up the cube
yourself'. This option allows you to recolor the cube to your
liking, using the available colors. The primary intended use for
this option is to allow you to describe to Rubik's Cube the
current state of any messed-up Cubes you might have lying around
your house. Once you've done that, you can either play with the
cube in that state, or, by exiting back to the Main Menu (press
Esc once to get back to the User's Menu, then once more to get to
the Main Menu) and selecting option A, have the computer solve
the Cube (be sure to save the solution to a file so you can use
it later to un-mess your Cube).
Selecting option <B> will take you to the Set Up Menu. Here
you will be shown a list of the colors available to you, and the
first part of the top face of the Cube will go black, waiting for
you to assign a color to it. You may select a color by typing
the first letter of the color (e.g., 'W' for white, or 'G' for
green). The current subcube area will be colored according to
your selection, and the next subcube will go black to indicate
which subcube comes next. You may continue assigning colors in
this manner until all subcubes have been defined, or you may
press Esc at any time to stop.
A caveat to keep in mind here: Once you begin playing with
this option you will quickly notice that Rubik's Cube skips over
the middle subcube of each face, preventing you from assigning a
color to it. Why is that? Well, there is one thing that's true
of the middle subcube of every face that's not true of any other
subcube: it never moves. Oh, it's true that center subcubes do
rotate around, but they never move out of their locations. While
the other subcubes wander around all over the Cube, the middle
subcubes stay put, so you always know right where to find them.
It can easily be seen, therefore, that the color a face is sup-
posed to be is determined by what color the middle subcube of
that face is. For example, the middle subcube of the computer's
Cube's top face is white, therefore, when the computer's Cube is
solved, the entire top face will be white. The computer's Cube,
when solved, will be white on top, blue on the right, red in
front, green on the left, orange in back, and yellow on the
bottom.
Therefore, before you begin assigning new colors to the
computer's Cube, you must first decide what color you own Cube's
faces are supposed to be, then pretend they are really the
computer's colors. For example, if your Cube's top face is
supposed to be blue, when you describe it to the computer you
must call it white; i.e. every time you come to a blue subcube on
your own Cube, type 'W' instead.
3. Resetting the Cube
The next option, '<C> Reset cube to original state', will
cause Rubik's Cube to abandon the current state of the Cube and
restart it in the original, solved state. This feature is par-
ticularly useful, for example, if you've gotten hopelessly lost
while playing with the cube and want to just start over, or if
you've tried setting up the cube yourself and discovered you've
assigned it an insoluble state. In either case, with this option
you can wipe the slate clean and start all over again.
4. Saving the Current State
Option <D>, 'Save current state' allows you to store the
current state of the Cube in a file on disk for later recall.
Possible uses here are, for example, if you're right in the
middle of solving the Cube and Mother calls you to supper ('Ok,
Mom. Be right there!'). Hey, no problem! Just save the current
state and go eat dinner. You can then start right where you left
off after the dishes are done (yes, I said AFTER the dishes!).
Or, if you've just arrived at an especially neat arrangement
(like that nifty checkerboard pattern you had a couple of weeks
ago) that you don't want to lose, you can save it, too.
When you select this option, you will be prompted in the
Message window for a file name. You can enter the name (up to
eight letters) or just press Return or Esc to abort the save.
Rubik's Cube will automatically tack on an extension of '.SAV'
when writing the file to disk. First, however, it will check to
see if there is already a file on disk by the name and inform you
if it finds one.
5. Restoring a Saved State
This option is the corollary to the previous one. This
allows you to restore a previously saved state. You will be
prompted in the Message window for a file name (again, up to
eight characters) and Rubik's Cube will automatically assume an
extension of '.SAV'. If no file with that name is found, the
appropriate message is displayed in the Message window, otherwise
the file is read in and the Cube restored accordingly.
Again, to return to the previous menu, just press Esc.
IV. Some Final Comments
Well, that's The Cube. What do you think? It's my sincere
wish that you derive oodles and oodles of intense pleasure from
it, or at least that it provides occasional relief from the drear
of the day. Or, if it gets added to your collection of public
domain software never to be looked at again, I guess I can't
complain too much. Lord only knows how much PD stuff I have
floating around on various disks that I haven't looked at since
time immemorial. But I do hope you like it enough to at least
trot it out once in a while.
Just to let you know in advance, here are some of the en-
hancements I have in mind for future editions of Rubik's Cube
(that is, assuming I ever get around to putting out future edi-
tions):
o The ability to record the moves you make in a file on
disk, so you go back later and see just how the heck you
got to where you are.
o Going to a pull-down menu system and/or the use of func
tion keys and mouse to select options.
o The ability to move around the Cube using arrow keys when
setting up the cube. This will be much nicer, for
example, if you want to change just one subcube, than
having to go through all the previous subcubes to get to
it. It will also allow you to go back and correct any
mistakes you made without having to start over.
o Routines to allow aborting the computer's solving the
Cube. It takes, on an 8 mhz XT, about 3 minutes to solve
the Cube (I can solve it faster than that myself);
currently, once you've chosen that option you're stuck
until it's done. This will allow you to abort in the
middle.
If you have any other comments, good, bad or otherwise (no
complaints, though. After all, what have you got to complain
about? You get this for free; I'm the one who slaved for months
writing it), or any suggestions for improvements or enhancements,
you can reach me on my favorite BBS:
Computers for Christ #11
(708) 362-7875
Vernon Hills (Chicago), Ill.
1200/2400/9600
PC-Pursuitable
Or through the US Mail at:
W6999 King Rd.
Poynette, Wisc. 53955
(608) 635-2165
V. Disclaimer
As per the usual: the author hereby offers no disclaimers as
to the suitability or performance of this software on any comput-
er, and bears no responsibility for any resulting damage or loss,
financial or otherwise.
Notice of Copyright
This software is owned by me, Calvin Culver, with the
exceptions of those portions which are copyrighted by Borland,
International. However, I hereby release it to the public
domain, and grant anyone the right to freely distribute it as
contained herein. My only requirement is that you distribute it
"as is" with all files together and intact, INCLUDING ALL
DISCLAIMERS AND COPYRIGHT NOTICES, and that you don't try to
claim my work as your own (that's called plagiarism, folks, or
theft). You may make any modifications you like on your own
computer, but please distribute only the original. Regardless of
what you may think of my programming skills or the quality of the
software, this program is a product of many hours of labor on my
part, and I would appreciate it if credit is given where credit
is due (in other words, please keep my name associated with it).
This copyright notice should in no way be taken to mean that
I relinquish any rights with respect to future editions and
enhancements of the software, nor does it require me to release
such software to the public domain. And finally, it does not
allow anyone to make any profit from it without my express writ-
ten permission in advance. You may, at your discretion, charge a
nominal fee, enough to cover costs of shipping and/or disks if
you decide to distribute it in that manner, but you may not sell
this program, nor bundle it with other software to be sold, nor
use it as an incentive for purchase, without first obtaining my
permission.
Thank You
This release is a token of my gratitude for all the fine
public domain software I've been the recipient of over the years.
Hmm. Kind of wordy, wasn't it? But I think I've covered
everything now.
E N J O Y !