Corning Community College


Data Structures


Project #1: FreeCell Variant Implementation




Objective

To gain an understanding of pointer-based stack data structures and their use in algorithms.

Overview

The intent of this project is to explore the use of pointer-based stack data structures through the implementation of a FreeCell-based card game.

If you are not familiar, please reference the Wikipedia article on FreeCell.

Requirements

Your task (either individually or in groups), is to implement a specific card game in a particular language. I am going to require diversity amongst card games implemented and programming languages used. So whatever path you decide to embark upon, I must be made aware and approve.

You must:

Game Variations

The reason I have chosen these games is that they involve a level of memory allocation, which has similarity to how the actual computer's hardware works. There may be additional games that fall under this category. If you find one and would like to implement it, let me know and I can ascertain if it is appropriate.

Programming Language Variations

Technically I'd allow any language that allows for linked data structures; but the above four are the most common students at CCC are likely to have encountered.

A caveat, I am only officially supporting C and C++, as those are the languages I will be using in class (predominantly C).

FreeCell Rules

Borrowed from Wikipedia:

Construction and layout

Building during play

Moves

Victory

Stack Operations

A card game is an excellent example of stack usage. When moving cards, I want to see push/pop operations taking place with respect to the various “storage locations” the cards can reside (foundations, cells, etc.)

To better understand the impact of stacks on these card games, be sure to play some games. Once you are familiar with the rules, specifically take notice of the functionality the stacks enable for the playing of the game.

Code Formatting

To facilitate the readability of your code, when preparing your code for submission, I'd like for you to make sure certain qualifications are met:

If you'd like, I have configured a facility on Lab46 to enable you to conveniently beautify your code to the ANSI/Allman style of coding. This is my preferred coding style, and would help me to better read your code.

So, if you aren't already consistent at code formatting (some have well-established coding habits and their code, although styled slightly different than mine, is still far more readable because it is consistent), please go through the following exercise for all your source files.

In this example, I will assume your files are called: main.c, list.c, and freecell.h

lab46:~$ cd src
lab46:~/src$ indent main.c
lab46:~/src$ indent list.c
lab46:~/src$ indent freecell.h
lab46:~/src$ 

You will find that a backup of your original formatted source code is saved in files called main.c~, list.c~, and freecell.h~. But the plain .c files are now nicely formatted.

If you find yourself tracking down elusive bugs and have experienced an unbalanced curly brace… you may want to consider passing your code through indent so as to save yourself some work and time. You'd be amazed what a little code beautification will do for you.