soliterminal 0.0.0-stage → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -1,3 +1,369 @@
1
- # Temporary Holding Version
1
+ # soliterminal
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ **Klondike solitaire for the terminal, with a solver watching every move.**
4
+ Every deal is proven winnable before you see it. The header says, move by move,
5
+ whether you can still win, and a move that loses the game is caught the moment
6
+ you make it: one key takes it back. Played entirely from the keyboard, with no
7
+ dependencies, and your game waits for you whenever you have to go.
8
+
9
+ [한국어](README.ko.md)
10
+
11
+ ![A game of soliterminal: the solver's line, a losing move caught, and one key to take it back](docs/demo.gif)
12
+
13
+ ```
14
+ soliterminal · Klondike · Draw 1 Moves 46 03:41 Win ✓
15
+
16
+ q w r t y u
17
+ ░15░ 4♦ A♦ [A ] [A ] [A ]
18
+ ↺2
19
+ a s d f g h j
20
+ K♣ ░░░░ 3♣ ░░░░ X♣ ░░░░ ░░░░
21
+ Q♥ 8♠ ░░░░ ░░░░ ░░░░
22
+ J♣ 7♦ ░░░░ ░░░░ ░░░░
23
+ X♦ 6♣ 6♦ ░░░░ ░░░░
24
+ 9♠ 5♦ 5♠ J♠ 5♥
25
+ 8♦ 4♣ 4♥
26
+ 7♠ 3♥ 3♠
27
+ 6♥ 2♠
28
+
29
+ › Holding column 4. Where does it go?
30
+ ── Draw 1 won 29/42 (69%) streak 3 longest 7 best 02:52 ──
31
+ q draw w waste a-j columns i to foundation z undo
32
+ arrows select space pick/drop tab card size esc menu
33
+ ```
34
+
35
+ <sub>The recording is a real game with large cards. This is compact cards (`Tab`), as drawn in any terminal; X is a ten.</sub>
36
+
37
+ ## Highlights
38
+
39
+ - **Every deal can be won.** The solver proves each new deal winnable before
40
+ you see it.
41
+ - **It tells you when you have lost.** The header shows, move by move, whether
42
+ the game can still be won. A losing move is caught at once, and `z` takes it
43
+ back.
44
+ - **Warnings before you make a mistake.** While you think, the solver looks one
45
+ move ahead. Pick up cards with a losing place to go and you are warned,
46
+ without being told which place. When winning takes every redeal you have
47
+ left, the header says so too.
48
+ - **Keys where the piles are.** The key above each pile is the key in the same
49
+ place on your keyboard: the top letter row for the top of the board (`q` the
50
+ stock, `w` the waste, `r` to `u` the foundations) and the home row for the
51
+ seven columns (`a` to `j`). No function keys, so it works the same in any
52
+ terminal, laptop or editor. Arrow keys work too.
53
+ - **Your game keeps.** Quit any time; the next start carries on with the board,
54
+ the undo history and the clock. The clock also stops while you are in another
55
+ window.
56
+ - **A record of every deal.** Each game is kept with its seed: won or lost,
57
+ time, moves, the move that lost it, and how hard the deal was. Replay any of
58
+ them, or type in a seed.
59
+ - **Follows your terminal.** Everything but the cards uses your terminal's own
60
+ 16-color palette, in one color family of your choice. Large or compact cards,
61
+ plain-ASCII and no-color modes.
62
+
63
+ ## Install
64
+
65
+ soliterminal needs [Node.js](https://nodejs.org) 20 or later.
66
+
67
+ ```sh
68
+ npm install -g soliterminal
69
+ soliterminal
70
+ ```
71
+
72
+ Or try it without installing:
73
+
74
+ ```sh
75
+ npx soliterminal
76
+ ```
77
+
78
+ ## How to play
79
+
80
+ Klondike in one paragraph: build the four foundations up from ace to king, one
81
+ suit each. In the seven columns, cards go down in alternating colors (a red 6
82
+ on a black 7), and only a king may start an empty column. A face-down card
83
+ turns over once it is uncovered. When you are stuck, draw from the stock.
84
+
85
+ ### Moving cards
86
+
87
+ Press the key of the pile the cards come **from**, then the key of the pile they
88
+ go **to**. `f` then `g` moves cards from column 4 onto column 5; how many is
89
+ worked out from where they land. Press the same key twice (`f` `f`) and they go
90
+ to the best spot, a foundation if they can.
91
+
92
+ | Key | Pile |
93
+ |---|---|
94
+ | `q` | Draw from the stock. When it is empty, turn the waste over (a redeal) |
95
+ | `w` | The waste |
96
+ | `a` `s` `d` `f` `g` `h` `j` | Columns 1 to 7 |
97
+ | `i` | The right foundation for the card: the usual way to send a card home |
98
+ | `r` `t` `y` `u` | One particular foundation |
99
+
100
+ Each key sits straight above or below its pile's neighbours: `q` over `a`, `w`
101
+ over `s`, `r` over `f`, and so on. `e` is over column 3, where the top row has
102
+ a gap, so it does nothing. Foundations are not tied to a suit: an ace starts
103
+ any empty one, and `i` picks for you. When every card is face up, the game
104
+ plays itself out.
105
+
106
+ The keys follow the US (QWERTY) layout. On other layouts they are the same
107
+ letters in other places; the arrow keys work everywhere.
108
+
109
+ ### The cursor
110
+
111
+ If you would rather point than press pile keys:
112
+
113
+ | Key | Action |
114
+ |---|---|
115
+ | `←` `→` | Move along the row |
116
+ | `↑` `↓` | Move to the pile straight above or below (column 1↔stock, columns 2 and 3↔waste, columns 4 to 7↔foundations) |
117
+ | `↓` in a column | Choose how many cards to move: the cursor goes onto the top card of the run (say a K), then one card further down each press (Q, J, …). The chosen card is tinted, and it moves with every card below it. `↑` goes back |
118
+ | `Space` | Pick up or put down at the cursor. On the stock, draw |
119
+ | `Enter` | Send the cursor's cards to the best spot. The cursor stays where they came from, on the card that turns up there |
120
+ | `Esc` | Put held cards back. With nothing held, open the menu |
121
+
122
+ ### Keys and the menu
123
+
124
+ | Key | Action |
125
+ |---|---|
126
+ | `z` | Undo, as far back as the deal (`Backspace` too) |
127
+ | `Tab` | Large or compact cards |
128
+ | `?` (or `/`) | Hint: asks first, then shows the solver's next move (see [Hints](#hints)) |
129
+ | `Esc` | The menu |
130
+ | `x` | Quit (asks first; your game is kept) |
131
+ | `Ctrl+Q` | Quit at once; your game is still kept (`Ctrl+C` too) |
132
+
133
+ Everything else is in the menu. Press the letter in brackets, `(N)ew game`, or
134
+ choose with `↑` `↓` and `Enter` (or `Space`); `Esc` backs out. Every other
135
+ question works the same way.
136
+
137
+ | Menu | Action |
138
+ |---|---|
139
+ | New game | A new deal (asks first if a game is under way: giving it up is a loss) |
140
+ | Restart this deal | Start over (asks first; not once it is won) |
141
+ | Draw 3 / Draw 1 instead | At once on an untouched deal, otherwise from the next one |
142
+ | Hint | Same as `?` |
143
+ | Play a seed or a recent game | Type a seed, or pick one of your games |
144
+ | Statistics | Your record, per draw mode |
145
+ | Keys and rules | The keys |
146
+ | Quit | Your game is kept |
147
+
148
+ After a win the results offer Quit too: the next start deals a new game. The
149
+ `Win 0%` choices offer it as well, and keep the game.
150
+
151
+ Three redeals are allowed by default (`--redeals` changes it). How many are
152
+ left is always shown under the stock: `↺2`, in red at `↺0`.
153
+
154
+ ## Playing with the solver
155
+
156
+ ### The header
157
+
158
+ The header always says where you stand:
159
+
160
+ | Header | Meaning |
161
+ |---|---|
162
+ | `Win ✓` | This position can still be won |
163
+ | `Win ✓!` | It can still be won, but only by using every redeal left: no trip through the stock to spare |
164
+ | `Win ⚠` | The cards in your hand have a place to go that loses |
165
+ | `Win …` | Checking, usually for a fraction of a second |
166
+ | `Win ?` | Not settled yet; a longer look carries on in the background |
167
+ | `Win 0%` | It can no longer be won |
168
+
169
+ At `Win 0%` the board shakes, the loss goes on record straight away, and you
170
+ choose: back to the last winnable position (`z` does this too), start the deal
171
+ over, a new deal, or play on (`Esc`). If the game was lost a few moves back, the
172
+ dialog says how many, and going back goes to just before them.
173
+
174
+ ### Losing your way to a win
175
+
176
+ The move that lost the game is remembered for the rest of the deal. Go back and
177
+ try it again and it is refused: `This move lost the game last time, so it is
178
+ blocked. Try another.` Each loss shuts one more door, so however many times you
179
+ lose, the way to the win stays open. The loss counts, and so does the win that
180
+ follows.
181
+
182
+ Sometimes the solver proves a loss a few moves later without settling which of
183
+ those moves lost it. Then the first of them is only suspected: you are warned
184
+ once, and doing it again goes ahead. Once it is proven, it is blocked too.
185
+
186
+ The blocked moves are shared by every window playing the same deal, survive
187
+ quitting, and are forgotten once the deal is won or left for another.
188
+
189
+ ### Warnings
190
+
191
+ While you think, the solver looks at every position one move away. When you
192
+ pick up cards that have a losing place to go, the message line turns red:
193
+ `⚠ Careful: one of its two places loses the game.` It does not say which place;
194
+ that is still your call. Put them there anyway and it is `Win 0%` straight
195
+ away, with `z` taking back just that move.
196
+
197
+ Everything the solver works out is remembered for the deal, restarts included,
198
+ so a mistake made once is caught instantly the next time.
199
+
200
+ ### Hints
201
+
202
+ The solver sees the face-down cards, so it may know of a win you cannot see:
203
+ moving part of a run, say, or taking a card back down from a foundation. Press
204
+ `?` at any time, as often as you like: it asks once, then shows the solver's
205
+ next move toward a win. While the solver is still checking a position, or
206
+ when no win from it is confirmed, it says so instead. Go once through the whole
207
+ stock without playing a card (or press `q` with nothing left to draw) and the
208
+ game tells you on its own that a move is there.
209
+
210
+ ## Your games
211
+
212
+ ### Saved as you play
213
+
214
+ Quit whenever you like: the next `soliterminal` carries on with the same board,
215
+ the whole undo history and the clock. Only a finished game is not kept. The seed
216
+ of the deal is printed when you quit.
217
+
218
+ The clock runs only while the game's terminal has focus, so time spent with your
219
+ agent does not count. Most terminals report focus (kitty, WezTerm, iTerm2,
220
+ Windows Terminal, GNOME Terminal, Konsole); in tmux, turn on
221
+ `set -g focus-events on`. Where focus is never reported, the clock just runs.
222
+
223
+ There is one saved game. Start soliterminal in a second window and it picks up
224
+ the same game; whichever window saves last is the one kept. A game finished in
225
+ both windows still counts once.
226
+
227
+ ### Statistics
228
+
229
+ Every game is kept with its seed, and the statistics are worked out from those
230
+ games, separately for Draw 1 and Draw 3: games played, won, win rate, current
231
+ and longest streak, best time and fewest moves.
232
+
233
+ A game goes on record when it ends: won, proven lost (a loss, which ends your
234
+ streak), or given up for another deal (also a loss). Going back after a proven
235
+ loss carries on as a new try: given up, it is a loss of its own, and won, a win. Drawing from the stock alone does not make it a game.
236
+ Starting a deal over carries on the same game, and quitting only pauses it.
237
+ Several windows can play at once: each finished game is added to the record as
238
+ a line of its own, so none overwrites another.
239
+
240
+ ### Choosing a deal
241
+
242
+ Play a seed or a recent game (in the menu) lists your games, newest first:
243
+
244
+ ```
245
+ soliterminal · Deals
246
+
247
+ Seed Draw 1 (← → switches)
248
+
249
+ Your games
250
+ Seed Draw Result Time Moves Redeals Level When
251
+ › 707746170 1 lost @86 06:40 86 hard 11-25 15:07
252
+ 109483114 1 won 06:52 131 2 11-25 13:40
253
+ 46732994 1 gave up 12:10 36 medium 11-25 11:50
254
+ 3291647763 3 won 03:05 98 0 11-24 18:03
255
+
256
+ Type a seed, or choose a game with ↑ ↓. Enter plays it; esc goes back.
257
+ Playing another deal gives up seed 2902541007: it counts as a loss.
258
+ ```
259
+
260
+ Choose a game with the arrows and press `Enter` to play it again, or type any
261
+ seed (`←` `→` switch the draw mode). A typed seed is not checked first: the
262
+ header tells you once the solver has judged it.
263
+
264
+ - **Result.** `lost @86` means the 86th move (counted as in the header) made the
265
+ game unwinnable. `gave up` means it was left while it might still have been
266
+ won. `no win` means the deal itself could not be won.
267
+ - **Redeals.** For a win, how many times the waste was turned over.
268
+ - **Level.** A lost deal is rated in the background, a few seconds on a spare
269
+ thread. The solver follows a winning line and counts the places where a move
270
+ loses and the places with only one way on: `easy`, `medium` or `hard`, and
271
+ `…` while it is being rated.
272
+
273
+ A deal you have won is never dealt again, and cannot be chosen again in the same
274
+ draw mode. A deal you lost before says so when it comes back, with the date
275
+ (`lost before 11-25 15:07` above the status bar).
276
+
277
+ ### Sharing results
278
+
279
+ Nothing leaves your computer on its own. When your finished games reach 100,
280
+ and again at 200, 300 and so on, soliterminal asks once, right after a win and
281
+ before the results, whether to send them to open Klondike research data. It
282
+ never asks in the middle of a game or when you start one. Say no (`Esc`) and it asks again
283
+ at the next hundred; agree (`Enter`) then, and the games not sent yet go, up to
284
+ 1,000 at a time. There is no way to send smaller batches: a server taking a
285
+ game at a time from everyone would only be kept busy for nothing.
286
+
287
+ What is sent for each game: the seed, draw mode, redeal limit, won or lost,
288
+ time, moves, redeals used (wins), the move that lost it and its level (losses),
289
+ and the day it was played, with a random name for the game. Besides that, a
290
+ random name for your installation, made up on your computer so that a game sent
291
+ twice counts once, and the soliterminal version. Nothing else: no name,
292
+ account, address, file paths or times of day. The server code is in
293
+ [`server/`](https://github.com/dayliver/soliterminal/tree/main/server), described in
294
+ [DEVELOPMENT.md](DEVELOPMENT.md#share-server).
295
+
296
+ ## Options
297
+
298
+ ```sh
299
+ soliterminal --draw 3 --theme blue
300
+ ```
301
+
302
+ | Option | Meaning |
303
+ |---|---|
304
+ | `--draw 1\|3` | Draw one or three cards at a time (default 1) |
305
+ | `--redeals N` | Times the waste can be turned over: 0 to 99, or `unlimited` (default 3). Deals are proven winnable under the same limit |
306
+ | `--compact` | Start with compact cards |
307
+ | `--theme NAME` | Color family: `green` (default), `cyan`, `blue`, `magenta`, `yellow`, `red`, `white` |
308
+ | `--seed N` | Play a particular deal, 0 to 4294967295 (not checked first). With a game under way kept, asks whether to carry on with it or give it up (a loss) |
309
+ | `--any-deal` | Deal any shuffle, not only winnable ones |
310
+ | `--ascii` | Plain ASCII: no box drawing, suit symbols or emoji |
311
+ | `-h`, `--help` | Show usage |
312
+ | `-v`, `--version` | Print the version |
313
+
314
+ | Environment variable | Meaning |
315
+ |---|---|
316
+ | `SOLITERMINAL_THEME=NAME` | Same as `--theme` (the option wins) |
317
+ | `SOLITERMINAL_CARD=ddd\|fff` | Card face: soft grey-white (default) or pure white |
318
+ | `SOLITERMINAL_STATS=PATH` | Your games and statistics (a log, one line per game) |
319
+ | `SOLITERMINAL_GAME=PATH` | The game in progress (default `current.json` next to the statistics) |
320
+ | `SOLITERMINAL_SHARE_URL=URL` | Where shared results go, for testing a share server |
321
+ | `COLORTERM=truecolor` | Exact card colors (otherwise the nearest 256-color ones) |
322
+ | `NO_COLOR=1` | No color at all |
323
+
324
+ Your data lives in `~/.local/state/soliterminal/` (`$XDG_STATE_HOME` if set), or
325
+ in `%LOCALAPPDATA%\soliterminal\` on Windows: `games.jsonl` holds your games,
326
+ one JSON line each, `current.json` the game in progress, `culprits/` the moves that lost the deals
327
+ being played, and `share.json` where
328
+ sharing stands. A `stats.json` from an earlier version is moved into
329
+ `games.jsonl` on first start and left in place.
330
+
331
+ ## Terminals
332
+
333
+ - **Size.** At least 56 columns. Height adapts: tall stacks of face-down cards
334
+ fold into one row when space runs short.
335
+ - **Large cards** draw their suits as emoji, which needs a terminal and font
336
+ that render emoji, such as kitty, WezTerm, Ghostty, iTerm2 or Windows
337
+ Terminal. Elsewhere the suits come out smaller; compact cards (`Tab`) look
338
+ right everywhere.
339
+ - **Colors.** The interface uses your terminal's 16-color palette, so it fits
340
+ your theme, light or dark. Only the cards have fixed colors.
341
+
342
+ ## Why
343
+
344
+ More and more of a developer's day goes to handing work to an AI agent and
345
+ waiting for it to finish. Those minutes are too short to start something else
346
+ and too long to stare at a scrolling log. soliterminal is something to do with
347
+ them: a quick game in the terminal you already have open, which you can drop the
348
+ moment your agent needs you and pick up again later, exactly where you left it.
349
+
350
+ ## Development
351
+
352
+ ```sh
353
+ npm install # TypeScript and Node types, for type checking only
354
+ npm start # play from source (Node 22.18+ runs the .ts files directly)
355
+ npm run check # type check and run the tests
356
+ npm run build # compile to dist/ for the npm package
357
+ npm run build:wasm # rebuild the solver engine from solver/ (needs Rust)
358
+ npm run preview # print one static frame
359
+ npm run peek # show the game in progress and whether it can still be won
360
+ ```
361
+
362
+ The game has no runtime dependencies. The solver's search is Rust compiled to
363
+ WebAssembly, shipped as one small file. How the code is laid out, the decisions
364
+ behind it, the share server and what is still open are in
365
+ [DEVELOPMENT.md](DEVELOPMENT.md).
366
+
367
+ ## License
368
+
369
+ [MIT](LICENSE)