November 25, 1996; Jerry Nowlin
Contributors: Phillip L. Thomas and Ralph E. Griswold
Requires: keyboard functions
This file is in the public domain.
This program was inspired by a solitaire game that was written
by Allyn Wade and copyrighted by him in 1985. His game was
designed for the IBM PC/XT/PCjr with a color or monochrome moni-
tor.
I didn't follow his design exactly because I didn't want to
restrict myself to a specific machine. This program has the
correct escape sequences programmed into it to handle several
common terminals and PC's. It's commented well enough that most
people can modify the source to work for their hardware.
These variables must be defined with the correct escape
sequences to:
CLEAR - clear the screen
CLREOL - clear to the end of line
NORMAL - turn on normal video for foreground characters
RED - make the foreground color for characters red
BLACK - make the foreground color for characters black
If there is no way to use red and black, the escape sequences
should at least make RED and BLACK have different video attri-
butes; for example red could have inverse video while black has
normal video.
There are two other places where the code is device dependent.
One is in the face() procedure. The characters used to display
the suites of cards can be modified there. For example, the IBM
PC can display actual card face characters while all other
machines currently use HDSC for hearts, diamonds, spades and
clubs respectively.
The last, and probably trickiest place is in the movecursor()
procedure. This procedure must me modified to output the correct
escape sequence to directly position the cursor on the screen.
The comments and 3 examples already in the procedure will help.
So as not to cast dispersions on Allyn Wade's program, I
incorporated the commands that will let you cheat. They didn't
exist in his program. I also incorporated the auto pilot command
that will let the game take over from you at your request and try
to win. I've run some tests, and the auto pilot can win about
10% of the games it's started from scratch. Not great but not
too bad. I can't do much better myself without cheating. This
program is about as totally commented as you can get so the logic
behind the auto pilot is fairly easy to understand and modify.
It's up to you to make the auto pilot smarter.
____________________________________________________________
Note:
The command-line argument, which defaults to support for the VT100,
determines the screen driver. For MS-DOS computers, the ANSI.SYS driver
is needed.
Source code |
Program Library Page |
Icon Home Page