Skip to content

Seng3694/fortunes-foundation-solver

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Fortune's Foundation Solver

This program is used to solve the solitaire game featured in the Zachtronic's Solitaire Collection called Fortune's Foundation.

It uses a depth-first-search approach which means it does not find the fastest solution (least amount of card moves). But it can find a decent solution by sorting its moves by some carefully chosen heuristics. The program does not automatically play the game for you. It only solves the input you provide. Entering the state of a board is tedious and so is replaying the solution it outputs. This program is not meant or designed to be used frequently. I just really like Fortune's Foundation Solitaire and wanted to write a solver for it.

Usage

Run the ffs command line tool with your input file as an argument and it will try solving it.

./build/ffs my_input_file.txt

There is currently no mode to go move by move. It will output a list of moves. It might be easier to read by redirecting the output to a separate file like:

./build/ffs my_input_file.txt > my_input_file_solution.txt

Input

The input file is a simple domain specific language. You can set the state of your game with keywords. Cards are specified by a single letter for their suite (major arcana = m, cups = c, swords = s, wands = w, pentacles = p) followed by a number for their value (0 to 21 for major arcana and 1 to 13 for the other suites). Example m0 being Major Arcana 0 (the fool) or p13 being king of pentacles. The stacks field represents the eleven stacks in the game. The first card in a row is the bottom most card of a stack. Please check the input example for more information.

Here is an example game state (to avoid copyright problems an ascii version instead of an in-game screenshot):

example state

Here is how the corresponding input file would look like:

major_left=1;
major_right=21;

minor_wands=4;
minor_cups=7;
minor_pentacles=7;

stacks={
  { w10, s4, m2, s8, s2, w5, p8, p9, p10, p11 },
  {  },
  { w6, w7, w8, w9 },
  { w11 },
  { p12, c13, s13, m5, m6, m7 },
  { c9 },
  { s9, s12, m3, c10, m4, w12, s7, s6, s5 },
  { m20, c11, m13, m14 },
  { m12, s10 },
  { m19, m18, m17, m16, m15 },
  { p13, c8, c12, w13, s11, s3, m8, m9, m10, m11 }, 
};

Here is the output of the program for this state (zero based stack indices):

==== solution ====
move from 0 to 1
move from 10 to 1
move from 10 to 8
move from 7 to 9
move from 4 to 1
move from 0 to block slot
move from 6 to 0
move from block slot to 0
move from 10 to 6
move from 10 to 7
move from 8 to 5
move from 9 to 8
move from 7 to 9
move from 6 to 8
move from 6 to 7
move from 4 to 9
move from 6 to 10
move from 0 to 7
move from 8 to 10
move from 2 to 9
move from 10 to 9

Dependencies

This project uses the toolbelt library for utilities like data structures and bit operations.

Build

The project can be built by running make or make release=1. The solver will be in the build directory.

git clone --recurse-submodules https://github.com/Seng3694/fortunes-foundation-solver ffs
cd ffs
make release=1
./build/ffs input_example.txt

Future Plans

  • proper command line interface and reporting wrong inputs better
  • while this project uses assertions heavily, it does not have any unit tests yet
  • there is still room for improvement in the solver

License

This software is licensed under the MIT License. See LICENSE for more information.

About

a program to solve any solvable fortune's foundation solitaire state

Topics

Resources

License

Stars

Watchers

Forks

Contributors