The code contained three modules and a header file that
implemented many macros. The module
card.c
contained several
routines for inputting and outputting cards. It knew how to
translate a user-readable format such as AH
,
10S
, 5C
or
QD
to a card struct.
The header file state.h
defined the data structures used to represent cards, columns
and states, and the macros that were used to query and
manipulate them. The module
state.c
implemented input
and output to entire states, as well as functions to compare
cards and columns, and a function to "canonize" states.
(Where "canonizing" means sorting the columns to avoid
duplication.)
The file freecell.c
contained the solve_for_state
function and the main
function.
solve_for_state
called itself
recursively, and contained a lot of duplicate code that
searched for existing states and added them to the
collection. (I managed it using copy and paste)