CS 696: Advanced OO
Spring Semester, 1997
Project: Solitaire
To Lecture Notes Index
San Diego State University -- This page last updated Apr 8, 1997
Contents of Project: Solitaire
- How solitaire games are played1
- Klondike
- Spider
CS596 Project
1) Design and implement a program to play the solitaire card game klondike. A
user of the program should not be allowed to make illegal moves. Optional
features of the program include, but are not limited to providing the user with
hints, allowing backtracking and allowing the user to save games. The rules
for klondike are given below. You will be graded on your design, program and
documentation.
2) (Optional) Design a program to play spider. What parts of the design for
klondike can be reused in spider? How would your klondike design change if you
were designing a program to play both spider and klondike? The rules for
spider are given below.
All solitaire games are played with one or more full packs of 52 cards each. A
pack of cards contains four suits, each identified by its symbol, or pip:
spades, hearts , diamonds and clubs. Clubs and spades are black, hearts and
diamonds are red. Each suit contains thirteen cards: ace (A), king (K), queen
(Q), jack (J), 10, 9, 8, 7, 6, 5, 4, 3 and 2. Most solitaire games proceed in
the following way:
Some or all of the cards are distributed face up in some distinctive array,
forming the tableau. The tableau together with any other cards dealt at
the outset are often called the layout.
The initial array may be changed by building. Certain cards of the
tableau are immediately available for play, while others may not be played
until certain blocking cards are removed.
The first objective is to release and play into position certain cards called
foundations. The ultimate objective is to build up the whole pack onto
the foundations, and if that can be done the game is won.
If not all of the pack is laid out in the tableau at the beginning, the
remainder of the pack forms the stock, from which additional cards are
brought into play according to the rules of the game. Cards from the stock
which can find no place in the tableau or on foundations are laid face up in a
separate pile called the talon or waste pile.
In some games, the layout includes a special packet of cards called the
stock; any remainder of the pack not dealt out at the beginning is then
called the hand.
In many games a vacancy in the tableau created by the removal of cards
elsewhere, called a space, is of capital value in manipulating the
tableau.
The rank of cards in solitaire games is: K (high), Q, J, 10, 9, 8, 7,
6, 5, 4, 3, 2, A.
CARDS - One pack.
TABLEAU - 28 cards in 7 piles. The first pile, one card; the second, two
cards; and so on up to seven. The top card of each pile is face up; all others
are face down.
Deal from left to right by rows; first row: one card face up and six face
down; second row: a card face up on the second pile, and one face down on each
other pile; and so on.
FOUNDATIONS - The four aces. Each ace, as it becomes available, must be played
to a row above the tableau. Foundations are built up in suit and sequence.
OBJECT - To get the four suits built up onto the foundations up to the
kings.
BUILDING - Any movable card (from tableau, stock or talon) may be placed only
on a card next-higher in rank than the bottom card of the unit, and of opposite
color. If more than one card is face up on a tableau pile, all such cards must
be moved as a unit. Example: (diamond)3, (club)4, (heart)5 may be moved as a
unit onto (spade)6 or (club)6. When there is no face-up card left on a pile,
the next card below is turned face up and becomes available.
SPACES - May be filled only by kings.
STOCK - The rest of the pack after the tableau is dealt forms the stock. Turn
up cards from the top of the stock one by one and build each if able. The
stock may be run through only once. (Variant. Go through the stock by
threes without limit.)
TALON - Place unusable stock cards face up on a talon pile. The uncovered
card of the talon is always available for play, provided the next card of the
stack has not been turned.
CARDS - Two packs shuffled together.
TABLEAU - Ten piles of five cards each, dealt by rows. The first four cards of
each pile are dealt face down, the top cards face up. All play is made on the
tableau; there are no foundations and no talon.
BUILDING - The top card of each pile may be moved, together with all below it
which follow it in ascending suit and sequence. A sequence of available cards
may be broken at any point and some left behind. Example: Pile from
top down shows (heart)4, (heart)5, (heart)6, (club)7; the first one, two or
three cards may be moved as a unit, but 7 may not be moved until the covering
three cards are removed.
When all face-up cards on a pile are removed, the next card below is turned
face up and becomes available.
A moveable unit of cards may be placed either in a space or on a card of rank
next-higher than the bottom card of the unit, regardless of color or suit.
Example: (heart)J may be moved onto any one of the four queens. A king
can be only moved into a space.
OBJECT - To assemble thirteen cards of a suit, in ascending sequence from
top down (ace to king) on top of a pile. Whenever a suit is so assembled, lift
it off and discard it from the game. The solitaire is won if all eight suits
are so cast out.
SPACES - May be filled with any moveable unit.
STOCK - When all possible or desired moves on the tableau come to a standstill,
deal another row of ten cards face up on the tableau piles. Before such a deal
may be made, all spaces in the tableau must be filled. The final deal
comprises only four cards, which are placed on the first four piles from the
left. (Variant. The four extra cards are added face down to these
piles in laying out the tableau.)