Table of Contents

Data Structures Project 7: Card Game "FreeCell", "Forty Thieves", "Eight Off", or "Baker's Game"

A project for COURSENAME by YOUR NAME OR GROUPMEMBER NAMES during the SEMESTER YEAR.

This project was begun on DATE and is anticipated to take X AMOUNT OF TIME. (Upon completion you can correct this with the actual length).

This project was supposed to be a final project, but Matt changed his mind…not sure if that's good or bad.

Objectives

State the purpose of this project. What is the point of this project? What do we hope to accomplish by undertaking it?

Prerequisites

In order to successfully accomplish/perform this project, the listed resources/experiences need to be consulted/achieved:

Background

State the idea or purpose of the project. What are you attempting to pursue?

Upon approval, you'll want to fill this section out with more detailed background information. DO NOT JUST PROVIDE A LINK.

Providing any links to original source material, such as from a project page, is a good idea.

You'll want to give a general overview of what is going to be accomplished (for example, if your project is about installing a web server, do a little write-up on web servers. What is it, why do we need one, how does it work, etc.)

Scope

Give a general overview of your anticipated implementation of the project. Address any areas where you are making upfront assumptions or curtailing potential detail. State the focus you will be taking in implementation.

Attributes

State and justify the attributes you'd like to receive upon successful approval and completion of this project.

Procedure

The actual steps taken to accomplish the project. Include images, code snippets, command-line excerpts; whatever is useful for intuitively communicating important information for accomplishing the project.

The first step was to become familiar with the rules and vocabulary for the 4 card games. Not only do I need to memorize C vocabulary, now I need to learn some Solitaire vocabulary :-X (A glossary of solitaire terms can be found here):

1. "FreeCell":

2. "Forty Thieves":

3. "Eight Off":

4. "Baker's Game":

The next step is picking a game to actually code. My initial choice is “FreeCell” as it seems the easiest to code. Before you play a card game, you first need a deck. Since “FreeCell” uses only one standard deck, there is only a total of 52 cards used:

Black ♣ Red ♦ Red ♥ Black ♠
A♣ A♦ A♥ A♠
02♣ 02♦ 02♥ 02♠
03♣ 03♦ 03♥ 03♠
04♣ 04♦ 04♥ 04♠
05♣ 05♦ 05♥ 05♠
06♣ 06♦ 06♥ 06♠
07♣ 07♦ 07♥ 07♠
08♣ 08♦ 08♥ 08♠
09♣ 09♦ 09♥ 09♠
10♣ 10♦ 10♥ 10♠
J♣ J♦ J♥ J♠
Q♣ Q♦ Q♥ Q♠
K♣ K♦ K♥ K♠

To “shuffle” the deck, first load the suite into a Doubly Linked List. Then use the rand() C function to pick a random node. The node is pushed onto the deck stack and removed from the list (Black ♣ will be nodes 1 - 13, Red ♦ will be nodes 14 - 26, Red ♥ will be nodes 27 - 39, Black ♠ will be nodes 40 - 52). This process is repeated until the Doubly Linked List is empty then the entire deck can be dealt.

I MIGHT (time permitting) try to implement an “easter egg”. In the HIGHLY UNLIKELY (but possible) event that the card combination in the 4 foundations is '8♠ A♣ A♠ 8♣' (the "Dead Man's Hand" in Poker); the program will exit and print the message “BANG! You're Dead. You got the Dead Man's Hand.”.

Code

/*
 * hello.c - A sample "Hello, World!" program
 * 
 * written by NAME for COURSE on DATE
 *
 * compile with:
 *   gcc -o hello hello.c
 *
 * execute with:
 *   ./hello
 */
 
#include <stdio.h>
 
int main()
{
    printf("Hello, World!\n");    // Output message to STDOUT
    return(0);
}

Execution

Again, if there is associated code with the project, and you haven't already indicated how to run it, provide a sample run of your code:

lab46:~/$ ./helloworld
Hello, World!
lab46:~/$ 

Reflection

Comments/thoughts generated through performing the project, observations made, analysis rendered, conclusions wrought. What did you learn from doing this project?

One thing I learned was that there are unsolvable games for FreeCell. Another idea that I had was writing a game of chess (or Suicide Chess) for the next semester instead of a FreeCell game.

References

In performing this project, the following resources were referenced:

Back to my Portfolio
Back to my Opus