Solitaire Specification, Simulation and Solution System

David Newton
University of St Andrews
Senior Honours Project 2005-2006


Abstract

The aim of this project was to construct a system to specify, play and solve games of Solitaire. The approach taken involved specifying states of play in terms of the collections of cards (piles) involved in each game, the rules associated with each pile and the cards within them at each point, in a way that could be manipulated automatically by a solver.

The system to solve games is based on the concept of building a tree of possible states from the root, moved through by a series of valid moves and eventually ending at a goal state (one in which all the required cards are on piles designated as goals). As states are moved through, the moves that lead to their possible child states are stored in a stack, allowing moves both from the current state and earlier states if the need to backtrack arises. Selection of moves from a state is done according to priorities laid out in the specification of the game.

Specification of games is handled through XML files, each of which contains the definitions and rules of the piles to be used, the cards to be dealt into them initially (whether fixed or random) and a few recommended strategies for solving a game, so that the search method used by the solver is more refined. The attributes used in the XML specification are extensive enough to make it possible to specify a variety of different games.

Documentation

Project Report - Details on the objectives of the project and the approach taken to achieve them. (PDF)

User Guide - An explanation of how to use the delivered system. (PDF)

Maintenance Document - Information on the classes used and guidelines for updating the system. (PDF)


JavaDoc pages - Details of the classes written for the project, in JavaDoc form. (HTML)

UML diagram - A diagram showing the relationships between the classes in the system. (GIF)


Source Code

All code is in the form of Java source, and can also be found in the "src/cs4099" folder. AbsoluteConstraints and AbsoluteLayout do not contain original code, but are used under the terms of the Sun Public Licence.

AbsoluteConstraints

AbsoluteLayout

Card

Desktop

FileFilter

Game

Interpreter

Main

Move

Pile

Solver

State

StateStack

StateWriter