
Programming projectDesign and buildDrawing 12 of 33
2D
Solitaire
A browser Solitaire I built to practise separating game rules from the screen. One engine drives three games, Klondike, FreeCell and Spider, and you can play it right here on this page.
- StatusPlayable, 2026
- GamesKlondike, FreeCell and Spider on one engine
- Built withPlain JavaScript, no framework and no build step
- Engine907 lines of rules with zero DOM calls
- DealsDeterministic, so deal #4412 comes back the same every time
Sheet 02 of 08/Why
A small game with a lot of state
Solitaire looks simple until you write down everything one drag can do: flip a hidden card, empty a column and complete a foundation, all at once.


Sheet 03 of 08/Split
The engine cannot see the screen
engine.js makes no DOM calls at all, so ui.js never decides whether a move is legal, it just asks the engine.



Sheet 04 of 08/Moves
Undo is just the move run backwards
Every move is stored as a reversible delta instead of a board snapshot, so undo is that same delta run backwards and redo runs it forwards again.
Sheet 05 of 08/Honest
The solver says maybe, so it says maybe
When the solver can't confirm a deal is winnable within its search budget it says so and deals anyway instead of pretending, and for Spider it doesn't even try.
Sheet 06 of 08/Look
Adjustable down to the felt
Almost everything about how it looks and plays, table colour, card size, suit palette, whether you drag or click, is a setting, and every one of them is remembered next time you open it.

Sheet 07 of 08/Next
What I would do differently
If I rebuilt this, I'd merge drag, click-to-move and keyboard into one shared way of producing a move instead of three separate paths that happen to do the same thing.
PL 07The full-screen page at iebisen.com/2d-solitaire, which is the same build as the one embedded on this page.