Writing a game of patience
Every patience in Dog Watch is one file, and you can write your own. If your favourite patience or variant is not here, the quickest way to it is to copy the file of a game like it and change a few fields. This is the guide to doing that, and the reference for every field.
Two ways in
As a mod, with no compiling. Put your file in your own games folder, and Dog Watch loads it after its own games the next time it starts:
| System | Folder |
|---|---|
| Linux | ~/.local/share/dogwatch/games/, or $XDG_DATA_HOME/dogwatch/games/ |
| macOS | ~/.local/share/dogwatch/games/ |
| Windows | %APPDATA%\dogwatch\games\ |
Make the folder if it is not there. Any file ending .ron in it is read, in name order. It appears on the menu’s Patience page under its family (or under YOUR OWN if it names none), g steps round every table, yours among them, and game and a word of its name (for example game two-cell) sits you down at it.
Built in. Put the file in Dog Watch’s own data/games/ folder and build again (cargo build --release). The built-in games are read in file-name order, which is the order g steps through them; the menu groups them by family.
A file that will not load is not silently skipped: the game’s log says which file and why, as in 1:9-1:14: Expected comma, or a game needs at least one column. Your game may not take the name of one Dog Watch already has; give it another.
A first variant, step by step
FreeCell with two cells instead of four (Blake and Gent give its odds: 79.544% of deals can be won). Copy data/games/03_freecell.ron to your games folder as two_cell_freecell.ron, and change four things:
name: "Two-Cell FreeCell", // was "FreeCell": a name of its own
cells: 2, // was 4
// classic: Some(MicrosoftFreeCell), // gone: Microsoft's deals were for four cells
odds: Some((
chance: 0.79544, // was 0.999988
means: CanBeWon,
source: "Blake and Gent (JAIR 2026, arXiv 1906.12314), Table 1: FreeCell with 2 cells, 79.544% ± 0.091%.",
)),
Change the rules and bio to say two cells, and that is the whole job. It keeps FreeCell’s family, so the menu shows it with FreeCell under OPEN PACKERS. A test in Dog Watch makes this very variant from the shipped file, loads it from a games folder, plays it and finds it in the menu (a_variant_is_a_copied_file_with_fields_changed), so the recipe stays true.
A layout of your own
Pyramid and TriPeaks lay their cards in a layout: places that overlap, a card playable once every card over it is gone. The layout is data, so a game with another shape is a file too. Each place says where it sits and which places cover it:
tableau: (columns: 28, deal: Layout, build: Nothing, empty: Nothing, moves: One),
layout: Some((
covered_down: true, // covered cards dealt face down, turned up when freed
places: [
(x: 6, y: 0, covered_by: [2, 3]), // place 1
(x: 5, y: 1, covered_by: [4, 5]), // place 2
// ...
(x: 0, y: 6), // nothing covers a card of the base
],
)),
xis across, in half a card’s width, so a row set half a card in from the one below it, as a pyramid’s is, hasxone more;yis the row, from 0 at the top. Each row is drawn overlapping the one above.covered_bylists the places lying over this one, by number, place 1 the first in the list. A place may be covered only by places after it, so the cards are dealt from the top down. The usual rule is the two places of the next row atxone less and one more.- The places are numbered in the file’s order, and the player uses those numbers:
22 to 27,25 up. Keep them row by row, left to right, aslookreads them. tableau.columnsmust equal the number of places,dealmust beLayout, and each place takes one card. The rest of the pack makes the stock.
Then choose how the cards leave: Golf’s heap (home: Heap and a stock with deals_to: Home, as TriPeaks) or pairs (home: Pairs(13), as Pyramid), and when the deal is won (won_when). A smaller pyramid of six rows is Pyramid’s file with row 7 deleted, the covered_by lists of row 6 deleted, and columns: 21; the stock then holds thirty-one.
Variants, family by family
The families are David Parlett’s, from The Penguin Book of Patience (1979, pages 7 to 9, as Wikipedia’s “Patience (game)” gives his classes): first by how much of the pack is in sight (closed, the cards come from a hidden stock; open, every card in sight from the deal; half-open, closed at first and open by the end), then by how the cards are built (builders build up on the foundations; packers pack down on the table first, the other way, so the cards can go home later; non-builders do neither). Dog Watch plays eight of his families. To make a game of one, start from its file:
Family (family:) |
What makes it | Start from | Change these fields |
|---|---|---|---|
Simple packers (SimplePackers) |
Pack the piles down, turn the hidden cards over, draw from the stock for more | 01_klondike.ron, 06_forty_thieves.ron |
stock (draw, redeals), tableau.deal, build, empty, moves, decks |
Reserved packers (ReservedPackers) |
Pack the piles down and feed them from a reserve | 12_canfield.ron, 13_canfield_one_at_a_time.ron |
stock.draw, stock.redeals, reserve, base, wrap, moves |
Half-open packers (HalfOpenPackers) |
No stock: some cards start hidden, and all come into sight | 07_yukon.ron |
tableau.deal, moves, empty |
Open packers (OpenPackers) |
Every card face up from the start | 03_freecell.ron, 17_fortress.ron |
cells, tableau.columns, tableau.deal, build, empty, moves, base, wrap |
Spiders (Spiders) |
All building on the table; whole suits leave it | 08_spider.ron, 09_spider_one_suit.ron |
suits, decks, tableau.columns, tableau.deal, stock.fill_first |
Simple builders (SimpleBuilders) |
Build up from the aces with few choices | 04_amazons.ron |
ranks, feeds, stock.idle_passes |
Reserved builders (ReservedBuilders) |
Play up from a spread in sight onto the home pile, as the stock allows | 10_golf.ron, 15_pyramid.ron, 16_tripeaks.ron |
tableau.deal, ranks, wrap, layout, home: Pairs(...), stock.top_up, won_when |
Planners (Planners) |
Each card turned is placed at once, to wait its turn | 11_calculation.ron |
home: Intervals([...]), tableau.columns |
Some worked examples, each a matter of values:
- Thoughtful Klondike (every card known) is not a file away yet: setting the down counts in
dealto 0 shows the 28 cards on the table, but the stock stays hidden, and no field turns it face up. - Chessboard is a shipped example:
18_chessboard.ronis17_fortress.ronwithbase: Chosen(the first card home sets every foundation’s start) andwrap: true(the ranks run round the corner, on the foundations and on the piles). Streets and Alleys (eight piles, building down in any suit): copy17_fortress.ron, settableau.columns: 8,deal: Columns([(0, 7), (0, 7), (0, 7), (0, 7), (0, 6), (0, 6), (0, 6), (0, 6)])andbuild: DownAnySuit. Fortress with two free cells: copy17_fortress.ron, addcells: 2. - Canfield, one at a time is a shipped example:
13_canfield_one_at_a_time.ronis12_canfield.ronwithdraw: 1. Canfield with partial piles (Wolter’s rules, 71.245% can be won): setmoves: Runs. - Klondike, three passes: copy
02_klondike_draw_three.ron, setstock: Some((draw: 3, redeals: Some(2))). The waste may be turned over twice, three passes in all. - Easy Street (any suit, any card to an empty column): copy
01_klondike.ron, setbuild: DownAnySuitandempty: AnyCard. - Spider in two suits: copy
09_spider_one_suit.ron, setsuits: [Hearts, Spades]. The pack keeps its 104 cards: four sets of each suit. - Spiderette (Parlett: one deck, seven columns as Klondike’s): copy
08_spider.ron, setdecks: 1,tableau.columns: 7,deal: Columns([(0, 1), (1, 1), (2, 1), (3, 1), (4, 1), (5, 1), (6, 1)]). The stock then holds 24 cards, three rows of seven and three over (the last row is short). - Golf, turning the corner (Wolter’s Golf-C, 93.0% can be won): copy
10_golf.ron, setwrap: true; a king and an ace then follow each other. Golf-B (a queen on a king, but no corner) is not a field yet. - Calculation with three foundations cannot be made: three foundations in steps hold 39 cards, and the file is refused because the steps must use the whole pack.
- Pyramid, all fifty-two (the strict rule Wikipedia gives; Keller and Masten’s solver takes all fifty-two away in 6.03% of one-pass deals, every card known): copy
15_pyramid.ron, addwon_when: Some(AllHome). The stock and the waste must then be paired away too. - Par Pyramid, the stock through three times (Keller’s name for it; Microsoft’s Pyramid also turns the waste over twice): copy
15_pyramid.ron, setredeals: Some(2). - Pyramid with no stock-to-waste pairs (Keller and Masten: 3.42% of pyramids cleared, every card known): copy
15_pyramid.ron, droptop_up: true. The stock is then face down, and only the card just turned, on the waste’s top, pairs with the pyramid. - TriPeaks, every card face up (the thoughtful variant Wikipedia names): copy
16_tripeaks.ron, dropcovered_down: true. - TriPeaks without the corner (Golf’s traditional rule on the peaks): copy
16_tripeaks.ron, dropwrap: true.The format
The file is RON (Rusty Object Notation): a record in brackets, field: value pairs separated by commas, text in double quotes, lists in square brackets, and // comments. The built-in games in Dog Watch’s data/games/ folder are worked examples: each says in its comments which of its fields differ from Klondike’s and why.
// Easy Street: Klondike, building in any suit, any card to an empty column.
(
name: "Easy Street",
about: "Klondike made easy: build down in any suit; any card fills a space.",
family: Some(SimplePackers),
stock: Some((draw: 1)),
tableau: (
columns: 7,
deal: Columns([(0, 1), (1, 1), (2, 1), (3, 1), (4, 1), (5, 1), (6, 1)]),
build: DownAnySuit,
empty: AnyCard,
moves: Runs,
),
rules: [
"Build the seven columns down in any suit.",
"Any card or run may go to an empty column.",
],
)
The fields
Only name, about and tableau are required. Every other field has a default, given here, so a file written for an older Dog Watch still reads.
| Field | What it says | Values | Default |
|---|---|---|---|
name |
The game’s name, shown in the header and the log | Text, unique among the games | (required) |
about |
A line or two: the game and its aim, said when you sit down | Text | (required) |
family |
The family the menu shows it under, after Parlett (see above) | Some(SimplePackers), Some(ReservedPackers), Some(HalfOpenPackers), Some(OpenPackers), Some(Spiders), Some(SimpleBuilders), Some(ReservedBuilders), Some(Planners), or None |
None: under YOUR OWN |
bio |
A short introduction for a player who has never played it: what kind of game it is, its aim, how a game goes, a little history. First in the HELP window (?) and in the manual |
A list of text, a sentence or a few each | none |
sources |
Where the introduction’s facts come from, a sentence each; write the introduction in your own words | A list of text | none |
rules |
The rules in whole sentences, for the HELP window (?) |
A list of text | none |
decks |
How many decks are shuffled together | 1 to 4 | 1 |
suits |
The suits the pack is made of, each repeated so a deck still holds 52 cards | One, two or four of Clubs, Diamonds, Hearts, Spades, in a list |
all four |
ranks |
The ranks the deck holds, in the order the foundations build. 1 is the ace, 11 to 13 the jack, queen and king | A list of distinct numbers from 1 to 13 | [1, 2, ..., 13], the full deck |
home |
How the foundations build (below) | UpBySuit, Heap, WholeSuits, Intervals([...]), Pairs(13) |
UpBySuit |
base |
The rank each foundation starts from | Lowest: the deck’s lowest, the ace. Ranks([1, 2, 3, 4]): foundation i starts with a card of that rank, taken from the pack at the deal (Calculation). Dealt: the card dealt after the reserve starts the first foundation, and the others start from its rank (Canfield). Chosen: the player chooses; until a card is home, any card may go to any empty foundation, and its rank is then every foundation’s start (Chessboard). An undo of that first card makes the choice free again, and a (all up) never makes it. Needs home: UpBySuit and wrap: true |
Lowest |
wrap |
The ranks run round the corner: a foundation goes on past the king to the ace until it holds every rank; on the piles a king goes on an ace (and, where they build up or down, an ace on a king too); on a heap, a king and an ace follow each other | true or false |
false |
reserve |
A pile dealt first, face down but for its top card, which plays home or onto a pile; nothing goes on it | Some((cards: 13, fills_spaces: true)); fills_spaces: an empty pile is filled from it at once while it lasts |
None |
home_returns |
Whether a card may come back down from a foundation onto a pile | true or false |
true |
stock |
The cards left after the deal, and how they come into play (below) | Some((...)) or None |
None: no stock |
cells |
Free cells, each holding one card | A number | 0 |
tableau |
The piles: how many, how they are dealt and how they build (below) | A record | (required) |
feeds |
Which piles feed the foundations | Any: any pile. Below: only the pile directly below each foundation; an ace goes to the leftmost empty foundation from any pile; and no card is dealt below a complete foundation. Below needs four piles and four foundations |
Any |
classic |
Classic numbered deals the game offers as an option, beside Dog Watch’s own shuffle: deals microsoft switches to them, deals strong back |
Some(MicrosoftFreeCell): Microsoft’s FreeCell deals 1 to 32,000 |
None |
odds |
How often the game comes out, shown beside the player’s record | Some((chance: 0.612, unknown: 0.018, means: CanBeWon, source: "...")); means and unknown below |
None |
layout |
Places that cover one another, in place of piles side by side: each one card, playable once nothing covers it (see “A layout of your own”) | Some((places: [(x: 6, y: 0, covered_by: [2, 3]), ...], covered_down: true)); covered_down: a covered card is dealt face down and turned up when freed |
None |
won_when |
When the deal is won | Some(TableClear): every place or pile empty, whatever the stock and the waste hold. Some(AllHome): every card of the pack home |
None: the home’s own rule, the table clear for Heap and Pairs, every card home for the others |
The foundations (home)
| Value | How they build | Games |
|---|---|---|
UpBySuit |
Four a deck, each up by suit from its base (the ace unless the file says), in the deck’s order, round the corner with wrap. A card may come back down onto a pile unless home_returns: false |
Klondike, FreeCell, Forty Thieves, Canfield |
Heap |
One heap, started by the stock’s first card. A card goes on it one rank up or down, any suit; nothing on the king; no turning the corner. The deal is won when the table is clear, whatever is left in the stock. Needs a stock with deals_to: Home |
Golf |
WholeSuits |
Four a deck, each taking a whole suit at once, from the deck’s top rank down to the ace in one suit, from the face of a column; no single card goes home and nothing comes back | Spider |
Intervals([1, 2, 3, 4]) |
One foundation a step: foundation i builds up by steps[i] whatever the suit, until it holds thirteen. Needs base: Ranks([...]) (where each starts), wrap: true (past the king and round from the ace), the full ranks, and steps that fill the pack exactly (four for 52 cards) |
Calculation |
Pairs(13) |
One discard pile, taking two free cards together whose ranks add up to the total (an ace 1, a jack 11, a queen 12, a king 13), or one card alone whose rank is the total, a king at 13. The player puts one card on its partner: on the table, on the waste, or on the stock’s top where it shows (top_up). The total is from 2 to 26. The deal is won when the table is clear, unless won_when says otherwise |
Pyramid |
The stock
| Field | What it says | Values | Default |
|---|---|---|---|
draw |
Cards turned at a time (unused where the stock deals rows) | A number, 1 or more | (required) |
deals_to |
Where the stock deals | Waste: onto the waste, the top card playable (Klondike). Columns: a row, one card onto each pile; with redeals above 0, the piles are gathered left to right and turned over when the stock runs out (Amazons). Home: onto the home heap (Golf) |
Waste |
redeals |
How many times the stock may be made again | Some(n), or None for as often as you like |
None |
idle_passes |
The deal is lost when the stock goes round this many times in a row with no card going up | Some(n), or None to play on |
None |
fill_first |
No row is dealt while a pile is empty | true or false |
false |
place_first |
Each card turned must be played, home or onto a pile, before the next is turned | true or false |
false |
top_up |
The stock’s top card lies face up and plays as the waste’s top does: it may be paired or sent home, and d turns it onto the waste (Pyramid). Only with deals_to: Waste |
true or false |
false |
The tableau
| Field | What it says | Values |
|---|---|---|
columns |
How many piles | A number, 1 or more |
deal |
How the piles are dealt | Columns([(down, up), ...]): for each pile, how many cards face down and then face up, left to right; the rest make the stock. (0, 0) is an empty pile. AllFaceUp: every card face up, dealt round the piles one at a time. Layout: one card to each place of the layout, in its order (and columns is the number of places) |
build |
How a card goes on a pile | DownAlternateColour: one rank lower, the other colour. DownSameSuit. DownAnySuit. UpOrDownSameSuit: one rank lower or one rank higher, the same suit, the direction changing as the player pleases (Fortress, Chessboard). Nothing: nothing builds on the piles. FromWaste: any card on any pile, but only from the waste, and nothing moves from pile to pile (Calculation’s waste piles) |
empty |
What an empty pile takes | AnyCard, KingsOnly or Nothing |
moves |
How many cards move from a pile at once | One. Runs: any run that builds, as one. SuitedRuns: a run moves as one only while it is in one suit (Spider). AnyFaceUp: any face-up card moves with every card on it, in order or not, if it builds on the target; where two would fit, the group nearer the face moves (Yukon). WholePile: only a whole pile moves, never part of it (Canfield). Supermove: as long a run as free cells and empty piles would let you move a card at a time |
The odds (means)
| Value | What the figure is | Shown as |
|---|---|---|
CanBeWon |
The game’s mathematical odds: the share of deals a solver finds winnable with every card known. A player who cannot see the hidden cards wins fewer | Solvable 90.5%; in words, “solvable 90.5%, with every card known” |
CarefulHand |
How often Dog Watch’s careful hand wins (send up all it can, else draw or deal; survey::patience_wins): close to the game’s own odds only where nearly every move is forced, as in Amazons |
Careful hand 31.5% |
Floor |
How often Dog Watch’s simple automatic player wins (survey::patience_floor): a floor under the odds, not the odds, where a thinking player wins more |
At least 12.9%; in words, “at least 12.9%, by our automatic player” |
Every game Dog Watch ships states CanBeWon, from its own solver or a published one; CarefulHand and Floor remain for a game of your own, and for testing the automatic players.
unknown: the range. The solver gives up on a deal when it has gone through its limit of positions, and such a deal is neither won nor lost: it is unknown. chance is then the share it won, and unknown the share it could not settle (from 0 to 1, with chance + unknown at most 1; 0 by default). The true share lies between them, and the table shows the range: chance: 0.612, unknown: 0.018 shows as “Solvable 61.2% to 63.0%”, and the sentence in records says how many deals the solver could not settle. Where the unknowns are too few to show at the figure’s precision, one figure shows.
Your variant is solved too. The solver plays your file’s own rules through the same engine as the table, so a copied and changed file is measured as Dog Watch’s own are (docs/math/patience.md, section 5). From Dog Watch’s folder, with your file in your games folder:
dogwatch --solve "Two-Cell FreeCell" --deals 1000
It prints the deals won, lost and unknown, the range and its 95% interval, and the time taken. --from K starts at deal K, --limit M sets the positions a deal (1,000,000 unless given; a larger limit settles more deals and takes longer), and --solve all solves every game. Copy the figures into your file’s odds, and say in source that they are Dog Watch’s solver’s, with the deals, the limit and the date.
Say where the figure comes from in source. A test holds every figure in Dog Watch’s own files to a fresh solve of the first 100 deals, within three standard errors (every_stated_figure_holds_on_a_small_sample), and every CarefulHand and Floor figure to a fresh survey; dogwatch --survey 10000 runs the automatic players’ survey for every game.
The checks a file must pass
Dog Watch refuses a file, with the reason, when:
- a field is misspelt or unknown, or a value is not one the tables above allow;
- it has no piles, or
dealnames a different number of piles thancolumns; - the deal (the reserve and a dealt base included) lays out more cards than the pack holds, or leaves cards over with no stock to hold them;
- the stock draws no cards;
ranksrepeats a rank, is empty, or names a rank outside 1 to 13;decksis not from 1 to 4, orsuitsrepeats a suit or names three;feeds: Belowis given with other than four piles and four foundations;home: Heapand a stock withdeals_to: Homeare not given together;home: Intervalshas a step outside 1 to 12, a stripped deck, steps that do not fill the pack, or nowrap: trueandbase: Ranks;base: Ranksdoes not name one rank of the deck for each foundation;base: Chosenis given withouthome: UpBySuitandwrap: true;- a
layoutis given withoutdeal: Layout, ordeal: Layoutwithout a layout; the layout’s places are not as many ascolumns; or a place is covered by itself, by a place before it, or by a number past the last; home: Pairshas a total outside 2 to 26;top_upis given with a stock that does not turn onto a waste;oddsgives a chance outside 0 to 1, or anunknownbelow 0 or that comes, withchance, to more than 1;- its name is already taken.
Sharing your games
Dog Watch is source-available, on Ghost Boat’s terms: mods and fan works may be shared if they credit Anthony Giacalone, say they are unofficial, and are free. See the terms of issue.
What a file cannot say yet
The engine grows as games ask for more, always as a field with a default, never as a rule for one game by name. Not yet possible in a file, each planned with the game that needs it:
- A card paired with the one covering it (Keller and Masten’s “overlap discards”, which more than double Pyramid’s solvable deals): a covered card never plays, even with its only cover as partner.
- Pairs of three or more ranks, as Elevens takes a jack, queen and king together.
- Fans: eighteen piles of three, too many to stand side by side at 80 columns, and a redeal that gathers and shuffles the table (La Belle Lucie, an open packer).
- A grid with gaps, cards moved into a space after the card one lower of their suit (Montana, also called Gaps, Parlett’s open non-builders).
- Foundations that build down, piles that build only up, and a stock turned face up (Thoughtful Klondike).