Bottom-up
Elementary functions to convert cards to and from their string representations. The u and p within the code stand for "user" and "perl" respectively, and mean user representation and internal C representation.
The first experimental version of Freecell Solver was written in Perl, and since then the naming convention for this case persisted.
This is a header file, but it can be considered a module due to the large amount of logic that it implements. It defines fcs_state_t (which represents a complete layout of the Freecell board) and of fcs_state_extra_info_t. It contains many macros for manipulating states and cards. (all of them should behave like function calls)
The fcs_state_extra_info_t contains the real positions of the stacks and freecells (refer to (SECTION_REF Canonisation and Normalisation)) and other things that the system uses but don't uniquely identify the state in the state collection.
This file contains various functions for manipulating states. Among the many things implemented in it are state canonisation, state duplicating, state comparison and converting to and from string format.
This module contains routines for handling individual moves (freecell → stack, stack → freecell, stack → stack) and various special moves as well as entire move stacks, which contain a sequence of moves to be played between two intermediate states.
This file manages the presets: configurations of stacks number, freecells number, decks number, and the other parameters that define how a game is played. A preset is a variant of Solitaire such as Freecell, Baker's Game, Simple Simon, Good Measure, etc. Many of them are categorised in PySol under different categories than the Freecell category. Moreover, some "Freecell-like" games such as Penguin are not supported by Freecell Solver yet.
The routines in the file enable applying a preset to an instance (by its name), applying a preset to an instance by a pointer to it, etc. It is also directly used by lib.c to maintain consistency across a sequence of consecutive instances.
This module contains move functions for Freecell tests. A move function receives an origin state and tries to deduce if moves of a certain kind are possible. It fills in a derived states list.
This code uses some macros defined in
meta_move_funcs_helpers.h
. It contains
both meta-move tests and atomic moves ones.
This file is similar in spirit to
freecell.c
only it contains
Simple
Simon move functions.
This file contains the
check_and_add_state
function - a function that is used to determine if a
reached state is found in the states collection and if so,
to insert it there. (an operation that can be considered
atomic).
It has several #ifdef'ed portions used to do it for the various types of states collections supported at compile time. It also has a function to collect the new stacks that were present in a similar fashion.
It is being used by the tests functions to put a state in the state collection.
This module contains the functions of the various scans and their auxiliary functions. The scan functions run tests and traverse the graph according to some inherent logic. Currently present are random-dfs/soft-dfs (soft-dfs is random-dfs without randomising groups), Best-First-Search (named A* in the code) and Breadth-First-Search (named BFS in the code) functions.
This module contains the logic that manages a solver instance, configures it and runs it. It used the scans module to perform the scan and other modules to configure it. Note that the interface presented here is very raw, and not meant to be used as an API.
This module contains the user API. It manages a sequence
of instances that can be used to solve a board, and then
recycled to solve another. It uses instance.c to perform
its operations, and do the actual configuring and solving.
It supplies the API header file
fcs_user.h
which contains one
function for doing any given operation, and these
functions are implemented in lib.c.
This module can be used to analyse an array of strings
(similar to that given to the main()
function) and configure a user instance accordingly. It
also implements reading such arguments from files and a
presets mechanism that can be used to assign names to
common configuration and load them.