poker-flopsolve 0.4.1 → 0.5.0-beta.1

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
@@ -25,7 +25,7 @@ const spot = defineSpot({
25
25
 
26
26
  const sol = solve(spot, { iterations: 500 });
27
27
 
28
- sol.ev(0); // chips per hand, out of position
28
+ sol.ev(0); // OOP's share of the pot, % (ev(0) + ev(1) = 100)
29
29
  sol.exploitabilityPercent(); // distance from equilibrium, % of pot
30
30
  sol.strategyAt(node, board); // per-combination action frequencies
31
31
  ```
@@ -62,6 +62,32 @@ number. The line reaching the selected node is spelled out above the grid —
62
62
  Solving runs in its own worker thread, so progress streams and **Stop** ends early while
63
63
  keeping the partial answer.
64
64
 
65
+ ## Benchmark page
66
+
67
+ A static page for anyone to measure the solver on their own machine, nothing installed:
68
+ pick two ranges on a 13×13 grid (drag to paint, with weights and preset ranges), a flop
69
+ with an optional turn and river, the pot, stack and betting, and press **Run benchmark**.
70
+ It solves in a Web Worker on every core, shows each phase as it goes, and reports the time
71
+ to each level of exploitability, iterations per second, where the time went, the tree's
72
+ size, the machine and the solution's root strategy, with a JSON report and a link to share.
73
+
74
+ ```bash
75
+ npm run site # build site/ into site/dist and serve it on http://localhost:5175
76
+ npm run site:build # build only
77
+ ```
78
+
79
+ `.github/workflows/pages.yml` publishes it to GitHub Pages each time `main` moves (set
80
+ Settings → Pages → Source to "GitHub Actions" once). Pages cannot send the cross-origin
81
+ isolation headers threads need, so the page registers its own service worker
82
+ (`site/coi-sw.js`) that adds them and reloads once; where that is not possible it solves on
83
+ one thread and says so.
84
+
85
+ The page offers **Exact** (`solve` to an exploitability target) and **Lite** (`solveLite`'s
86
+ recipe, stopped when the root play settles), and says in plain words what Lite simplified and
87
+ what it cannot tell you. Its memory limit defaults to 2 GiB on desktops reporting 8 GB or
88
+ more, 512 MiB on phones and 1 GiB otherwise (the solver's own browser default is 512 MiB);
89
+ a tree over the limit at 32 bits is solved at 16. Threads default to every core.
90
+
65
91
  ## Ranges
66
92
 
67
93
  ```
@@ -155,11 +181,51 @@ Each takes a value per round too. On a turn spot with four sizes, two raises and
155
181
  Raise caps per round (`maxRaises: [1, 2, 1]`) and a checked-down river (an empty
156
182
  `betSizes` row) were already available and trim the same way.
157
183
 
184
+ `removeActions` cuts single lines: each a bet, raise or shove named by the path of the node
185
+ it leads to, as `Solution.path` writes it (`'check bet 18.15'`, `'bet 41.25 call / allin
186
+ 975'`), with everything below it. Only the line named goes; the same size elsewhere stays.
187
+ Use it to keep three sizes where they matter and one elsewhere; `thinSizes` (below) is a
188
+ ready-made shape of that kind.
189
+
158
190
  `minWeight: 0.05` trims the ranges the same way: combinations weighted under 5% are
159
191
  dropped from both, which suits imported ranges full of hands at a percent or two.
160
192
 
161
193
  ## Reading a solved spot
162
194
 
195
+ `solution.ev(player)` is the player's **share of the pot**, in percent: what they win on
196
+ average per hand, as a percentage of the pot the spot starts with (`SpotConfig.pot`; on a
197
+ turn or river spot, that spot's starting pot). Folding, or losing every showdown, is 0%;
198
+ winning the pot uncontested is 100%; the two players' values add up to 100%. Percentages
199
+ compare directly across spots with different pots. On Ks 9d 4c with a 60 pot, for example,
200
+ `ev(0)` 70.8 and `ev(1)` 29.2 mean out of position wins 42.5 of the 60 chips on average
201
+ (the old chip reading was 12.5 / −12.5).
202
+
203
+ The pot used is `solution.evPot`. A subgame from `subgameAt` — and so `resolveSubgame` and
204
+ `LiteSolution.resolve`, nested or not — sets `SpotConfig.evPot` to the original spot's, so a
205
+ re-solved turn reports in the flop pot and its values read the same way down a hand. Folding
206
+ at a subgame's root then reads below 0: the chips put in on earlier streets, given up, as a
207
+ share of the flop pot (after a 30 bet and call into 60, folding the turn reads −50%).
208
+ `exploitabilityPercent` stays a percentage of the spot's own pot.
209
+
210
+ Up to and including 0.5.0-beta.0 `ev` was in chips, against a baseline where each player already owns half
211
+ the pot (folding −pot/2, the two summing to 0). That number is still there as
212
+ `solution.evChips(player)`, and per hand as `solution.handEvsChips(player)`; the conversion is `evChips = ev / 100 × evPot − evPot / 2`.
213
+ `Solver.valuesAt`, `pairValuesAt`, `rootValues`, the regrets and `ResolvedSubgame`'s
214
+ `alternative` and `entered` stay in chips on that baseline.
215
+
216
+ `solution.handEvs(player)` gives each combination's root EV, in % of `evPot` as `ev` is,
217
+ indexed like `COMBO_CARDS` (0 outside the range, on the board, or with no opponent hand to
218
+ face; those carry no weight). Weighted by range weight times the opponent mass each hand can
219
+ face, it averages to `solution.ev(player)`, and one pass serves both.
220
+
221
+ Both read the average strategy by default. With `approximations: { currentProfileEv: true }`
222
+ they read the current (regret-matched) profile instead: the strategy the next iteration would
223
+ play. Its per-hand EVs settle sooner. After 15 s single-threaded in a browser, their mean error
224
+ against a 0.045%-of-pot reference was 1.23% of pot against the average's 2.18% on As Kh 7d,
225
+ 0.11% against 0.37% on Ks 9s 4s, and 1.40% against 2.02% on a wide Qs Jh 2c. The cost is the
226
+ same. `strategyAt` and `reachAt` still show the average, so the EVs then belong to a
227
+ different profile from the strategy you read.
228
+
163
229
  `createRun` returns the solver itself as `run.solver`, for analysis after (or between)
164
230
  iterations, without changing anything:
165
231
 
@@ -203,6 +269,21 @@ resumes a solve exactly. Measured on a river spot to 0.1% of pot:
203
269
  | Stack 120 → 100 | 125 | 75 |
204
270
  | Pot 60 → 72 | 125 | 100 |
205
271
 
272
+ A solve of a nearby flop can seed one too, through a card relabelling that takes its board
273
+ onto this one. A rank swap keeps every hand's role, so a solve of AsKh6d read through
274
+ `rankSwap` of the 6 and the 7 plays 66 as 77:
275
+
276
+ ```ts
277
+ import { rankSwap } from 'poker-flopsolve';
278
+ const six = solve(defineSpot({ ...config, board: 'As Kh 6d' }), { targetPercent: 0.1 });
279
+ const seven = solve(defineSpot({ ...config, board: 'As Kh 7d' }), {
280
+ targetPercent: 0.5, warmStart: six, warmCards: rankSwap(4, 5), // ranks 0 = deuce … 12 = ace
281
+ });
282
+ ```
283
+
284
+ On the bench flop that reaches 0.5% of pot in 8 iterations instead of 52 (from AsQh7d,
285
+ 20). It needs the whole old solve: seeding only the flop's decisions saved at most 15%.
286
+
206
287
  ## Re-solving from a node
207
288
 
208
289
  Solve the whole spot with a coarse tree, then re-solve the street you are looking at
@@ -216,7 +297,9 @@ const detailed = solve(turn, { targetPercent: 0.3 });
216
297
 
217
298
  `solution.subgameAt(node, board, betting?)` returns the spot that starts at a node that
218
299
  opens a betting round. It carries the board dealt there, the pot and stacks as they stand,
219
- and each player's range as their reach there (`solution.reachAt`). Ranges accept these
300
+ and each player's range as their reach there (`solution.reachAt`), with `evPot` kept at
301
+ the original spot's pot so the re-solve's `ev` is a share of the flop pot (see
302
+ [Reading a solved spot](#reading-a-solved-spot)). Ranges accept these
220
303
  per-combination weights as well as notation. Measured on the bench flop: the coarse flop
221
304
  took 27 s and 150 MB with 3 threads. Each turn, re-solved with three sizes, two raises and
222
305
  a shove, took about 7 s and 15 MB. The same rich tree solved from the flop would need
@@ -231,11 +314,87 @@ This is *unsafe* re-solving. The subgame is solved for the ranges that arrive, s
231
314
  strategy can be exploitable in ways the original allowed for. It also does not make the
232
315
  earlier streets any more accurate than their coarse model of the future.
233
316
 
317
+ ### Full flop betting, re-solved turns
318
+
319
+ For a flop whose full tree does not fit, keep the flop's betting as it is and give the turn
320
+ and river one size, then re-solve each turn you look at with the full betting.
321
+ `resolveSubgame` does the re-solve; it is opt-in and tree-shaken away when unused.
322
+
323
+ ```ts
324
+ import { defineSpot, resolveSubgame, solve } from 'poker-flopsolve';
325
+
326
+ const full = { ...spot, betSizes: [[0.33, 0.75, 1.5]], raiseSizes: [[0.75]], maxRaises: 3, allowAllIn: true };
327
+ const blueprint = solve(
328
+ defineSpot({
329
+ ...full,
330
+ betSizes: [[0.33, 0.75, 1.5], [0.75], [0.75]],
331
+ raiseSizes: [[0.75], [0.75], [0.75]],
332
+ maxRaises: [3, 1, 1],
333
+ allowAllIn: [true, false, false],
334
+ runoutBuckets: 3,
335
+ }),
336
+ { targetPercent: 0.3, precision: 'i16' }, // in a browser, add `wasmStorage` (see below)
337
+ );
338
+ const turn = resolveSubgame(blueprint, node, board, {
339
+ player: 0, // whose strategy to refine
340
+ betting: { betSizes: full.betSizes, raiseSizes: full.raiseSizes, maxRaises: 3, allowAllIn: true },
341
+ iterations: 300,
342
+ });
343
+ turn.solution.strategyAt(0, 0);
344
+ ```
345
+
346
+ Measured on Ks 9s 4s (pot 55, stacks 975, the bench ranges) against the full tree solved
347
+ to 0.093% of pot (99 minutes, 2.3 GB at i16 on four threads):
348
+
349
+ | | blueprint, 1 turn/river size | + 3 runout buckets, i16 |
350
+ |---|---|---|
351
+ | storage | 264 MiB | 97 MiB |
352
+ | solve to 0.3%, Node, 4 threads | 27 s | 55 s |
353
+ | root EV error per hand, OOP / IP | 2.3 / 2.2% of pot (max 10.6 / 20.2) | 2.3 / 2.2% (max 10.1 / 19.5) |
354
+ | root size agreement, OOP / IP after a check | 98.6% / 65.4% | 100% / 62.0% |
355
+ | EV the root play loses at the full tree's values, OOP / IP | 0.027 / 0.022% of pot | 0.028 / 0.020% |
356
+
357
+ Size agreement compares which bet size each hand's EVs rank best in the blueprint and in
358
+ the full tree. It is fragile where sizes are near-tied. With the current solver, whose
359
+ average strategy changed while these runs were going, OOP's agreement reads 75%, and the
360
+ root EV error 2.0 / 1.9% of pot. The EV the root play loses held: 0.019 / 0.014% of pot.
361
+ That is the number to go by. IP's low size agreement after a check is near-indifference: only 15% of its betting hands
362
+ prefer one size by 0.5% of pot or more, the blueprint agrees on 89% of those, and its play
363
+ loses 0.02% of pot. The per-action EV errors are largest for the flop shove (11–33% of pot
364
+ for IP), a line neither tree plays. More turn/river sizes did worse here: two sizes
365
+ (0.33, 1.5) gave 4.4 / 5.7% EV error and three gave 4.7 / 6.1%, at 336 and 417 MiB. On the
366
+ rainbow As Kh 7d, which has about 4.5 times the runouts, the same blueprint is estimated at
367
+ 1.2 GiB f32, 363 MiB with buckets at i16.
368
+
369
+ A re-solved turn, over the 15 most-reached turn nodes, took about 12 s in Node on one
370
+ thread and 5–40 MiB. Against it, an opponent playing a best response with the full tree's
371
+ ranges gains, weighted by how often each turn is reached, 3.5–4% of the subgame's pot.
372
+
373
+ `resolveSubgame` re-solves without a safety gadget. Safe gadgets, which keep each opponent
374
+ hand from doing better than it did against the blueprint, were measured and made things
375
+ worse (4.2–6.2% of the pot); see [docs/APPROXIMATIONS.md](docs/APPROXIMATIONS.md). With
376
+ `measure: true` it reports each opponent hand's best-response value against the blueprint
377
+ (`alternative`) and against the re-solve (`entered`). A re-solved subgame is a `Solution`, so
378
+ a river below it can be re-solved from it in turn.
379
+
380
+ In headless Chromium (`poker-flopsolve/threads`, Ks 9s 4s), the blueprint with buckets at
381
+ f32 solved to 0.3% in 84 s on one thread and 25 s on four, and each re-solved turn took
382
+ 21 s and 6.6 s with 40 MiB. At i16 without `wasmStorage` it runs on the JavaScript engine,
383
+ about 190 s however many threads it has; with `wasmStorage` from
384
+ `poker-flopsolve/wasm-storage` it runs on the WebAssembly engine, threads included, which
385
+ is what brings the rainbow blueprint into a tab: see
386
+ [16-bit and compact storage on the WebAssembly engine](#16-bit-and-compact-storage-on-the-webassembly-engine).
387
+ A run holds its engine threads until `close()` (which `solve` calls for you), and
388
+ snapshots stay usable after it, so close the blueprint's run before re-solving.
389
+
390
+ `solveLite` packages this recipe, with sharing, sampling and a stop on the root play: see
391
+ [Lite mode](#lite-mode-solvelite) and [Choosing an approximation](#choosing-an-approximation).
392
+
234
393
  ## In a browser
235
394
 
236
395
  The package also runs in a browser, for the small solves a page wants: river spots and
237
396
  narrow turn spots. Bundlers pick the browser build (`dist/browser.js`) automatically
238
- through the `browser` export condition. It is the same solver, single-threaded:
397
+ through the `browser` export condition. It is the same solver, single-threaded by default:
239
398
 
240
399
  - no worker threads, so `workers` resolves to 1 (asking for more logs one warning);
241
400
  - no `SharedArrayBuffer`, so the page needs no cross-origin isolation headers;
@@ -245,12 +404,179 @@ through the `browser` export condition. It is the same solver, single-threaded:
245
404
  A solve blocks the thread it runs on, so host it in a Web Worker and step it in chunks;
246
405
  [`examples/browser-worker.ts`](examples/browser-worker.ts) does that with progress and a
247
406
  stop message in about sixty lines. Flop spots and wide turn spots belong in Node, where
248
- `workers` splits the runouts across cores.
407
+ `workers` splits the runouts across cores, or in a browser with threads turned on.
408
+
409
+ ### Threads in the browser (opt-in)
410
+
411
+ A page can split a solve across cores as Node does, with no approximation. Import
412
+ `enableThreads` from `poker-flopsolve/threads` and await it once, in the Web Worker that
413
+ solves, before solving:
414
+
415
+ ```ts
416
+ import { createRun, defineSpot } from 'poker-flopsolve';
417
+ import { enableThreads } from 'poker-flopsolve/threads';
418
+
419
+ const threads = await enableThreads(); // navigator.hardwareConcurrency, or 1 if unavailable
420
+ const run = createRun(defineSpot(config), { workers: threads });
421
+ ```
422
+
423
+ It starts `threads − 1` engine workers that share the WebAssembly engine's memory, exactly
424
+ as Node's threads do, so a fixed thread count gives the same answer as Node at that count
425
+ (bit for bit where the browser's V8 agrees with Node's on `Math.pow`, as it did in every
426
+ measurement here). They stay started between solves; a solve borrows them and gives them back on
427
+ `close()`. `enableThreads(1)` stops every thread no open run holds. Only the WebAssembly engine (the default) is
428
+ threaded; `engine: 'js'` or `precision: 'f64'` solve on one thread, and so do
429
+ `precision: 'i16'` and `compactStorage` unless the solve passes `wasmStorage` (below).
249
430
 
250
- `npm test` checks the browser build in headless Chromium against Node (skipped where
251
- Playwright is not installed), and `npm run bench:browser` times it beside Node.
431
+ Threads need:
252
432
 
253
- ## Performance
433
+ - a **cross-origin isolated** page, which gives `SharedArrayBuffer`. Serve the page
434
+ with these headers, and every script it loads from the same origin or with CORS:
435
+
436
+ ```
437
+ Cross-Origin-Opener-Policy: same-origin
438
+ Cross-Origin-Embedder-Policy: require-corp
439
+ ```
440
+
441
+ - the solve to run in a **Web Worker**, since a page's main thread may not block on
442
+ `Atomics.wait`;
443
+ - `blob:` workers allowed, if the page sets a Content Security Policy (`worker-src blob:`).
444
+
445
+ Where any of these is missing, `enableThreads` resolves to 1 and solves stay on one
446
+ thread; `threadsUnavailable()` says why. Without the import nothing changes: the main
447
+ bundle carries only a lookup for the threads, and a solve gives the same results as
448
+ before. The UI's dev server (`npm run ui`) sends the two headers.
449
+
450
+ On a 4-core container, headless Chromium, a flop solve to 0.3% of pot took 24.0 s on one
451
+ thread and 8.7 s on four (`npm run bench:browser:threads`).
452
+
453
+ `npm test` checks the browser build in headless Chromium against Node, single-threaded and
454
+ threaded (skipped where Playwright is not installed). `npm run bench:browser` times it
455
+ beside Node, and `npm run bench:browser:threads` times flop solves at each thread count.
456
+
457
+ ## Performance and approximations
458
+
459
+ A plain `solve` is exact: `exploitabilityPercent()` measures the real game and
460
+ `targetPercent` stops there. Everything that trades accuracy for time or memory is opt-in.
461
+ Pick a goal below, not a dozen options.
462
+
463
+ ### Choosing an approximation
464
+
465
+ | Goal | Use | Rainbow, As Kh 7d | Two-tone, Ts 9s 4h | Monotone, Ks 9s 4s |
466
+ |---|---|---|---|---|
467
+ | Fastest flop answer in a browser | [`solveLite`](#lite-mode-solvelite) | 35 s, 511 MiB; root loss 0.023 / 0.014 | 21 s, 426 MiB; 0.118 / 0.076 | 12 s, 253 MiB; 0.059 / 0.037 |
468
+ | Fits a phone, 512 MiB or less | `solveLite` on a spot with `compactStorage: {}`, solved with `wasmStorage` | 300 MiB, 27% slower (Node) | not measured | not measured |
469
+ | Better turn re-solves, in a tab | `solveLite` with `keepBudget: 150 * 2 ** 20`, `precision: 'i16'`, `wasmStorage` | 45 s, 534 MiB; re-solve gain 1.8 / 1.4 (1.3 / 1.1 at 800 it, 59 s) | 29 s, 467 MiB; 1.5 / 1.2 | 13 s, 315 MiB; 1.8 / 1.2 |
470
+ | The whole tree, in 2 GiB or less | [`largeTree`](#fitting-a-large-tree-largetree) | T: 155 s, 1.97 GiB (1.87 in Chromium); root loss 0.031 / 0.020 | not measured | `thinSizes` alone: 0.64 GiB at 32 bits |
471
+ | Exact | `solve(spot, { targetPercent })` | 9.2 s, 708 MiB (0.2%, Chromium) | 10.3 s (Node) | 5.6 s (Node) |
472
+
473
+ How each row was measured, all on 4 threads:
474
+ - **`solveLite`**: issue #47's betting (0.33 / 0.75 / 1.5 pot, a 0.75 raise, all-in, three aggressions;
475
+ pot 55, stack 975, the bench ranges), headless Chromium. Time is until the root play settles. Peak
476
+ memory includes a turn re-solve. Root loss is what OOP's root play / IP's play after a check give up
477
+ at the unshared blueprint's per-action values, % of pot. The phone row's 300 MiB is Node's peak on
478
+ rainbow. The re-solve row is issue #113's: the same blueprint at 16 bits, keeping the most-reached
479
+ flop lines that 150 MiB holds, the pick included in the time, stopped at the tolerance #123 set
480
+ for it. Its gain is an opponent's best response
481
+ to a re-solved turn, % of the subgame pot: plain lite gives 3.1 / 2.7, 4.0 / 3.3 and 3.6 / 3.6, an
482
+ unshared blueprint 0.4–0.7.
483
+ - **`largeTree`**: T, which is As Kh 7d with issue #47's betting on every street (17.2 GiB at 32 bits), in Node. Time is until
484
+ OOP's root loss comes within 0.02% of pot of its final value. Root loss is measured at the per-action values of
485
+ `thinSizes` alone at 32 bits, solved for 600 iterations, whose own play loses the same: the floor.
486
+ - **Exact**: the bench ranges and betting to 0.3% of pot (two-tone and monotone, Node), and the bench
487
+ `flop` spot to 0.2% in Chromium.
488
+
489
+ Every napkinpoker figure on this page (the goal table's notes and the inventory's costs) is an
490
+ aggregate score against napkinpoker's reference solves, whose fixtures are private (issue #119; see
491
+ [Every option on napkinpoker's reference solves](#every-option-on-napkinpokers-reference-solves)).
492
+
493
+ What the numbers mean:
494
+ - **`solveLite`**: decisions near-exact against an equilibrium opponent. Root play loses 0.072% of pot
495
+ at an exact full-game solve's values (issue #51's T₀, rainbow). On eight napkinpoker spots it lost
496
+ 0.034 / 0.135%, where the stored solves' own play loses 0.027 / 0.131. Per-hand root EVs are 0.5–1.9%
497
+ of pot off the unshared blueprint's and 2.9–3.9% off the full game's (T₀). In its own game,
498
+ exploitability plateaus a few % of pot, because the river is shared. Full-game exploitability is not
499
+ measured. A turn re-solved at your full betting gives a best-responding opponent 2.7–4.0% of the
500
+ subgame pot.
501
+ - **`largeTree`**: decisions near-exact against an equilibrium opponent, except where `thinSizes` cuts
502
+ a size the opponent plays. Against an exact full-tree solve, root play loses 0.04% of pot (T₀). On
503
+ seven napkinpoker spots OOP's root lost 0.04%, as an exact solve's does. IP's play after a check lost
504
+ 0.34% against 0.16%, because its 0.33 flop bet is cut there. Per-hand root EVs are 0.05% of pot off
505
+ the thinned tree's and about 1.5% (5.5% at worst) off the full tree's (T₀). In its own, thinned game,
506
+ exploitability is 0.35% of pot after 1,600 iterations. Full-game exploitability is not measured.
507
+ - **Exact**: exploitability is measured in the full game, every card dealt.
508
+
509
+ #### The presets
510
+
511
+ Both presets take any betting of yours and return what they changed, so nothing is silent:
512
+
513
+ ```ts
514
+ import { createRun, defineSpot, solveLite } from 'poker-flopsolve';
515
+ import { largeTree } from 'poker-flopsolve/wasm-storage';
516
+
517
+ const lite = solveLite(spot, { workers: 4 });
518
+ lite.changes.roundsSimplified; // ['turn', 'river']
519
+ lite.changes.notes; // ['turn: OOP loses the bet sizes 0.33, 1.5, all-in at 17 of the 19 such decisions the preset keeps', ...]
520
+
521
+ const { config, options, changes } = largeTree({ ...spot, maxBytes: 2.5 * 2 ** 30 }, { options: { workers: 4 } });
522
+ changes.sizesCut; // [{ street: 'flop', player: 'ip', facing: 'bet', sizes: [0.33, 1.5, 'allin'], ... }, ...]
523
+ const run = createRun(defineSpot(config), options);
524
+ ```
525
+
526
+ `changes.sizesCut` lists every bet, raise and shove size your tree offers and the preset's does not, by
527
+ street, player and whether it opens the betting or answers a bet. It also counts the decisions that lost
528
+ them. `changes.settings` lists every other setting the preset set or dropped, with your value and its
529
+ own. `changes.notes` says each in a sentence. `litePreset(spot)` returns what `solveLite` would solve
530
+ (`config`, `options` and `changes`) without solving it, for a page that steps its own run.
531
+
532
+ `largeTree` stays in `poker-flopsolve/wasm-storage`, beside the storage engine it needs. It returns
533
+ that engine in its `options`, so moving it to the main entry would mean either carrying the engine's
534
+ 36 KB in every build or loading it with a dynamic `import()`. The first breaks the promise that a build
535
+ without the import is unchanged. The second would make `largeTree` asynchronous, which is a breaking
536
+ change, and the build does not split chunks. `solveLite` needs no second engine and is in the main
537
+ entry.
538
+
539
+ ### Options inventory
540
+
541
+ Every opt-in, by status:
542
+ - **Preset-internal**: a preset sets it for you. Reach for it directly only to tune a preset.
543
+ - **Advanced**: measured and supported, for a caller who knows the trade.
544
+
545
+ Dead ends are removed rather than deprecated; [docs/APPROXIMATIONS.md](docs/APPROXIMATIONS.md) keeps
546
+ their numbers.
547
+
548
+ Costs are from napkinpoker's three 3-bet spots (issue #103) unless a section is named: storage and time
549
+ against the exact solve at equal iterations, root loss OOP / IP in % of pot (the exact solve's is
550
+ 0.059 / 0.054), and true exploitability.
551
+
552
+ | Option | Status | Engines | Refuses | Measured cost |
553
+ |---|---|---|---|---|
554
+ | `solveLite` / `litePreset` | preset | both | — | settled at 2.6× the iterations: 0.22× storage, 0.30× time, root 0.052 / 0.068, turn nodes 0.127, 1.89% exploitable ([Lite mode](#lite-mode-solvelite)) |
555
+ | `largeTree` | preset | WebAssembly | — | at 4× the iterations: 0.38× storage, 0.58× time, root 0.057 / 0.289 (IP's cut 0.33 bet), 0.39% exploitable in its own tree ([Fitting a large tree](#fitting-a-large-tree-largetree)) |
556
+ | `shareHistories` | preset-internal (lite) | both | — | 0.40× storage, 1.00× time, root 0.061 / 0.068, 1.89% exploitable |
557
+ | `compressRanges` (`solveLite`, or on its own) | advanced (a lite option) | both | a board that is not a flop | edits the ranges. Wide weighted ranges: 0.42–0.72× storage, 0.46–0.60× time, root play 1.2–2.7 points off where two Lite solves were 1.8–3.0 apart. Narrow ranges: little, and slower on a monotone flop ([Lite mode](#lite-mode-solvelite)) |
558
+ | `keepBudget` (`solveLite`), `shareHistories.keepLines`, `linesWithin` | advanced (a lite option) | both | — | turn re-solve gain within 0.1–0.8% of the subgame pot of an unshared blueprint's, against 3.0–4.2% from plain sharing ([History sharing](#history-sharing)) |
559
+ | `runoutBuckets` | preset-internal (lite) | both | — | folds nothing on napkinpoker's weighted ranges. Bench ranges, gap 3: 0.61× time, true exploitability 0.302 against 0.271 ([Runout buckets](#runout-buckets-and-coarse-start)) |
560
+ | `approximations.chanceSampling` | preset-internal (both) | both, threaded | — | at 4× the iterations: 0.69× time, root 0.057 / 0.056, 0.60% exploitable |
561
+ | `settle` | preset-internal (lite) | both | — | two strategy reads per check, no best-response pass |
562
+ | `thinSizes` | preset-internal (`largeTree`) | both | — | 0.74× storage, 0.66× time, root 0.067 / 0.294 (IP's cut 0.33 bet), 0.22% in its own tree |
563
+ | `precision: 'i16'` with `wasmStorage` | preset-internal (`largeTree`) | WebAssembly with `wasmStorage`, else JavaScript | — | 0.52× storage, 1.16× time, root 0.059 / 0.067, 0.37% exploitable |
564
+ | `compactStorage` | advanced (`largeTree`'s `storage: 'compact'`) | WebAssembly with `wasmStorage`, else JavaScript | `analysisOnly` | 0.37× storage, 1.37× time, root 0.063 / 0.080, 0.63% exploitable |
565
+ | `resolveSubgame` | preset-internal (`LiteSolution.resolve`) | both | — | blueprint plus re-solves: 0.68× time, turn loss 0.053 against 0.031 exact |
566
+ | `approximations.coarseStart` | advanced | both | `warmStart` | does nothing where buckets fold nothing (all of napkinpoker's spots), or beside `runoutBuckets` at its own gap or wider. Bench flops in Chromium at 15 s: root EV error 1.51 → 0.19% of pot ([Runout buckets and coarse start](#runout-buckets-and-coarse-start)) |
567
+ | `approximations.currentProfileEv` | advanced | both | `analysisOnly` | no more than reading EVs; per-hand EVs often 2–4× closer at equal iterations |
568
+ | `analysisOnly` | advanced | both, at 32 bits | `compactStorage`, `currentProfileEv` | loads a saved strategy; keeps no regrets |
569
+ | `warmStart`, `warmCards` | advanced | both | — | see [Warm starts](#warm-starts) |
570
+ | `minWeight` | advanced | both | — | edits the ranges: 2–5% less storage, up to 15% less time on napkinpoker's spots |
571
+ | `engine: 'js'` | advanced | JavaScript | — | the reference engine, about 2.4× slower; `precision: 'f64'` runs on it |
572
+ | `isomorphism: false`, `simd: false`, `algorithm: 'cfr+'` | advanced | both | — | exact; off switches for comparison |
573
+
574
+ `test/combinations.test.ts` solves every pair of `shareHistories`, `compactStorage`, `thinSizes`,
575
+ `runoutBuckets`, `chanceSampling`, `coarseStart`, 16-bit `wasmStorage`, `resolveSubgame`,
576
+ `litePreset` and `largeTree` (45 pairs); none is refused. Every approximation
577
+ tried and left out, with its numbers and issue, is in [docs/APPROXIMATIONS.md](docs/APPROXIMATIONS.md).
578
+
579
+ ### Exact speed
254
580
 
255
581
  Measured on an Apple M2, single threaded:
256
582
 
@@ -273,8 +599,10 @@ warm start and analysis works unchanged. With threads (Node), all of them share
273
599
  WebAssembly memory and split the runouts as below. It runs wherever it can — 32-bit
274
600
  storage, the default, and WebAssembly SIMD, which current Node and browsers have —
275
601
  and `run.engine` says which ran. `engine: 'js'` forces the JavaScript traversal;
276
- `precision: 'f64'` or `'i16'` use it too. Against the JavaScript traversal it is about
277
- 2.4× faster per iteration, and about 3× in Chromium.
602
+ `precision: 'f64'` uses it too, and so do `'i16'` and `compactStorage` unless the solve
603
+ passes `wasmStorage` (see
604
+ [16-bit and compact storage on the WebAssembly engine](#16-bit-and-compact-storage-on-the-webassembly-engine)). Against the JavaScript traversal it is about 2.4× faster per
605
+ iteration, and about 3× in Chromium.
278
606
 
279
607
  ### SIMD kernels
280
608
 
@@ -293,8 +621,21 @@ Chromium, exploitability checks ~8%.
293
621
  When swapping suits leaves the board and both ranges unchanged, a deal in one of those
294
622
  suits is the mirror image of a deal in another, and only one is solved. On a two-tone flop
295
623
  the two absent suits are interchangeable; on a monotone flop, all three. This is exact —
296
- the solver keeps mirrored hands' strategies tied together, so a stored runout stands for
297
- its mirrors with nothing lost — and it is on by default (`isomorphism: false` turns it off).
624
+ mirrored hands play alike, so a stored runout stands for its mirrors with nothing lost —
625
+ and it is on by default (`isomorphism: false` turns it off).
626
+
627
+ The same symmetry is used a second time inside each stored board: hands that mirror each
628
+ other there (on Ks9s4s, AhAd, AhAc and AdAc) are stored once, and every vector, regret and
629
+ strategy sum on that board shrinks with them. Card removal stays exact, because the fold and
630
+ showdown kernels still count each opposing hand's own cards. Measured single-threaded, ms
631
+ per iteration with the same iterations to every target:
632
+
633
+ | Flop | Hands stored on the river | ms per iteration | Memory |
634
+ |---|---|---|---|
635
+ | Ks9s4s, monotone, bench ranges | 245,916 → 171,442 | 78 → 62 | 38 → 27 MB |
636
+ | Ks9s4s, pairs and broadway | 264,184 → 177,944 | 80 → 59 | 41 → 28 MB |
637
+ | Ts9s4h, two-tone | 522,944 → 458,484 | 154 → 143 | 81 → 71 MB |
638
+ | AsKh7d, rainbow | 784,806 → 784,806 | unchanged | unchanged |
298
639
 
299
640
  | Flop, 4 threads | Runouts stored | To 0.3% of pot |
300
641
  |---|---|---|
@@ -307,58 +648,56 @@ runouts. To read a mirrored one, `spot.resolveBoard('Ts9s4h 7c')` gives the stor
307
648
  and how hands relabel onto it. Ranges that differ between suits anywhere — an exact combo,
308
649
  or a partial weight on one suit — have no symmetry to use, and solve as before.
309
650
 
310
- ### Runout buckets (approximate)
311
-
312
- `runoutBuckets: true` solves one turn or river card for several that play alike: two cards
313
- of one suit, neither pairing the board, equally connected to its straights, whose rank
314
- swap maps both ranges onto themselves. The stored card stands for the others with hands
315
- relabelled by the swap. A number instead of `true` is the widest rank gap allowed in a
316
- bucket (`true` is 1, the most cautious).
317
-
318
- It is an approximation — 55 on a 6 river and 66 on a 5 river sit on opposite sides of the
319
- board card, and no relabelling fixes that — so `exploitabilityPercent()` (and
320
- `targetPercent`) measure the bucketed game, and `run.trueExploitabilityPercent()` measures
321
- the strategy in the real one, every card dealt. How much it saves and costs depends on
322
- the ranges; suited connectors keep ranks apart, pocket pairs near the merged ranks cost
323
- accuracy. On AhKdQc, 4 threads, to 0.3% of pot in the bucketed game:
651
+ ### Accuracy targets
324
652
 
325
- | Ranges | Gap | Runouts | Time | True exploitability |
326
- |---|---|---|---|---|
327
- | Bench (wide, connectors) | exact | 2,352 | 13.2 s | 0.271% |
328
- | | 1 | 1,672 | 10.5 s | 0.278% |
329
- | | 3 | 1,348 | 8.0 s | 0.302% |
330
- | Pairs and broadway | exact | 2,352 | 9.3 s | 0.228% |
331
- | | 1 | 1,396 | 4.9 s | 0.482% |
332
- | | 3 | 1,088 | 4.2 s | 0.542% |
653
+ `solve(spot, { targetPercent })` stops as soon as exploitability reaches that percentage of
654
+ the pot, making `iterations` a cap rather than a plan. This is the cheapest way to cut solve
655
+ time, because the last decimal place of accuracy costs most of the run:
333
656
 
334
- ### 16-bit storage
657
+ | Target | Iterations | Time |
658
+ |---|---|---|
659
+ | 2% | 20 | 0.28 s |
660
+ | 1% | 24 | 0.26 s |
661
+ | 0.5% | 39 | 0.29 s |
662
+ | 0.25% | 57 | 0.35 s |
663
+ | 0.1% | 127 | 0.57 s |
664
+ | 0.05% | 200 | 0.73 s |
665
+ | none (500 iterations) | 500 | 1.43 s |
335
666
 
336
- A spot too big for 32-bit storage under `maxBytes` is solved at 16 bits instead
337
- (`precision: 'i16'` forces it). Regrets and strategy sums are stored as 16-bit integers with
338
- one scale per node and board, about halving memory. `estimate.compressedBytes` reports
339
- that size, and a spot is refused only if even that exceeds `maxBytes`. Measured on AsKh7d:
667
+ As a guide, 1% of pot is a sketch, 0.5% is enough to read strategies off, and 0.1% is
668
+ publishable. On the flop preset in the browser UI, a 0.5% target finishes in 2 s against an
669
+ estimated 24 s for the full iteration count.
340
670
 
341
- | Flop | Ranges | 32-bit | 16-bit |
342
- |---|---|---|---|
343
- | 1 size, 1 raise | 198 vs 165 | 150 MB | 85 MB |
344
- | 2 sizes, 1 raise | 198 vs 165 | 824 MB | 425 MB |
345
- | 2 sizes, 1 raise | 309 vs 424 | 1,645 MB | 836 MB |
346
- | 2 sizes, 2 raises | 309 vs 424 | 3,344 MB | 1,689 MB |
671
+ Checking is not free: it is a full best-response pass for both players, about one
672
+ iteration's work, spread across the same threads as the solve. Rather than pick a cadence, the solver predicts when the target will be met — CFR+
673
+ exploitability falls as roughly `C / T^p`, so two measurements pin the crossing — and checks
674
+ just short of it. On a 500-iteration run that is 7 checks and 4% overhead, against 50 checks
675
+ and 23% for a fixed cadence of 10.
347
676
 
348
- The 309 vs 424, two-size flop solved with two threads at a peak RSS of about 1.1 GB, so it
349
- fits a 2 GB machine. It reaches each accuracy target in the same number of iterations as
350
- 32-bit, but each iteration costs about 15–20% more, because every update re-encodes its
351
- block. Strategy sums round up or down at random, weighted by the remainder: rounded to
352
- nearest, small sums lose most of each iteration's contribution and exploitability stalls
353
- near 0.04% of pot. The randomness is a hash of the slot and iteration, so solves stay
354
- deterministic at any thread count.
677
+ `solution.stoppedAt` is `'target'` or `'iterations'`. The second with a target set means the
678
+ target was *not* reached and the answer is looser than asked for, which the CLI and the UI
679
+ both say out loud.
355
680
 
356
681
  ### Algorithm and benchmark
357
682
 
358
683
  The default update rule is Discounted CFR (`algorithm: 'dcfr'`, α 1.5, β 0, γ 3, with
359
684
  positive regret counted from the second iteration so the uniform first iteration is
360
- forgotten). CFR+ is still available as `algorithm: 'cfr+'`. The table below predates the
361
- 0.2.0 schedule, which needs 10–15% fewer iterations on flop and turn spots. `npm run bench` times a fixed river, turn, flop
685
+ forgotten). CFR+ is still available as `algorithm: 'cfr+'`.
686
+
687
+ Under DCFR, each iteration adds its strategy to the average without weighting it by the
688
+ hand's own reach, as postflop-solver does. With own-reach weighting, a hand that equilibrium
689
+ play stops sending to a node averaged out to its near-uniform first iterations there, so
690
+ continuing it off the path (browsing the hand, comparing an engine against the solve) played
691
+ close to random. On a turn spot after 300 iterations, near-uniform play among hands reaching
692
+ a node with under 0.1% of their starting weight fell from 8% to 0.6%. The cost, single-threaded
693
+ on the regression spots: exploitability at a fixed iteration count is up to about 50% higher
694
+ once it is small (turn, 400 iterations: 0.016% → 0.024% of pot), which is 0–14% more
695
+ iterations to 0.3% or 0.1% of pot (turn 79 → 88 and 143 → 163; flop 62 → 69 and 112 → 115)
696
+ and about the same to 1%. CFR+ keeps the own-reach weighting: its iterates oscillate, and
697
+ unweighted they averaged to 2–3× the exploitability.
698
+
699
+ The table below predates both this change and the 0.2.0 schedule, which needs 10–15% fewer
700
+ iterations on flop and turn spots. `npm run bench` times a fixed river, turn, flop
362
701
  and two-tone flop. Measured in a 4-core cloud container, seconds of solving to reach each
363
702
  target (exploitability checks excluded):
364
703
 
@@ -390,47 +729,27 @@ bundled. Measured in a 4-core cloud container, time to 0.3% of pot:
390
729
  | Flop | 4 | 9.1 s | 5.1 s | 1.8× |
391
730
  | Monotone flop | 4 | 2.9 s | 1.4 s | 2.1× |
392
731
 
393
- 0.2.0, still in JavaScript, was 4–6× behind; the WebAssembly engine below is most of
732
+ 0.2.0, still in JavaScript, was 4–6× behind; the WebAssembly engine above is most of
394
733
  the difference.
395
734
 
396
- ### Accuracy targets
397
-
398
- `solve(spot, { targetPercent })` stops as soon as exploitability reaches that percentage of
399
- the pot, making `iterations` a cap rather than a plan. This is the cheapest way to cut solve
400
- time, because the last decimal place of accuracy costs most of the run:
401
-
402
- | Target | Iterations | Time |
403
- |---|---|---|
404
- | 2% | 20 | 0.28 s |
405
- | 1% | 24 | 0.26 s |
406
- | 0.5% | 39 | 0.29 s |
407
- | 0.25% | 57 | 0.35 s |
408
- | 0.1% | 127 | 0.57 s |
409
- | 0.05% | 200 | 0.73 s |
410
- | none (500 iterations) | 500 | 1.43 s |
411
-
412
- As a guide, 1% of pot is a sketch, 0.5% is enough to read strategies off, and 0.1% is
413
- publishable. On the flop preset in the browser UI, a 0.5% target finishes in 2 s against an
414
- estimated 24 s for the full iteration count.
415
-
416
- Checking is not free: it is a full best-response pass for both players, about one
417
- iteration's work, spread across the same threads as the solve. Rather than pick a cadence, the solver predicts when the target will be met — CFR+
418
- exploitability falls as roughly `C / T^p`, so two measurements pin the crossing — and checks
419
- just short of it. On a 500-iteration run that is 7 checks and 4% overhead, against 50 checks
420
- and 23% for a fixed cadence of 10.
421
-
422
- `solution.stoppedAt` is `'target'` or `'iterations'`. The second with a target set means the
423
- target was *not* reached and the answer is looser than asked for, which the CLI and the UI
424
- both say out loud.
425
-
426
735
  ### Workers
427
736
 
428
737
  `solve(spot, { workers })` splits the runouts across threads, the calling thread included:
429
738
  `workers: 2` is the caller and one worker thread. Storage is indexed runout-outermost, so
430
- each thread owns a disjoint slice of shared memory and takes no locks. Only the round above
739
+ each runout's storage is walked by one thread at a time and no thread takes a lock. Only the round above
431
740
  the split stays on the main thread alone, because CFR+ clamps regrets at zero and partial
432
741
  sums cannot be added through a clamp. Exploitability and EV passes are split the same way.
433
742
 
743
+ On the WebAssembly engine the split round's boards are not cut into fixed slices: every
744
+ thread takes the next board off a shared queue, the costliest first by what each took on the
745
+ previous traversal, until none are left (issue #133). Under chance sampling a board's work
746
+ changes from one iteration to the next, and fixed slices left the slowest thread walking
747
+ about 13% longer than the mean; the queue keeps it under 1%. On As Kh 7d with `solveLite`'s
748
+ blueprint in headless Chromium, 4 cores, it settled in 49.3 s on 2 threads and 28.1 s on 4,
749
+ where fixed slices took 57.9 and 33.7, the same 400 iterations, and a turn re-solve took
750
+ 12.8 and 7.0 s instead of 14.5 and 8.6. `node --import tsx bench/threads/profile.ts` prints
751
+ where a threaded traversal's time goes. The JavaScript engine's pool keeps fixed slices.
752
+
434
753
  Measured on a 133 vs 145 combo spot, 8 cores:
435
754
 
436
755
  | Workers | Turn, 400 iters | Flop, 100 iters |
@@ -445,11 +764,34 @@ Measured on a 133 vs 145 combo spot, 8 cores:
445
764
  a 2-core machine still splits; `workers: 1` stays on one thread. A river spot has a single runout and silently stays single-threaded whatever is
446
765
  asked for.
447
766
 
448
- Results are bitwise deterministic at a fixed worker count, but agree with a different count
449
- only to floating point: a worker sums its own slice before the totals are summed across
450
- workers, which associates the same addition differently, and the non-linear CFR+ clamp
451
- compounds that rounding. Measured, the gap sits at 1e-15 through 300 iterations and reaches
452
- 1e-7 by 2,000 — always orders of magnitude below the exploitability at that point.
767
+ A thread that fails mid-iteration fails the solve instead of hanging it: the step throws, as
768
+ does every step after, and the run must be closed and solved again. A thread killed without
769
+ any chance to report it (a Node worker out of heap, a worker the browser kills) is caught by
770
+ a backstop instead: the main thread waits for the others at most 20× its own share of the
771
+ step, and never less than a minute, before it gives up on them.
772
+
773
+ On the WebAssembly engine, each board's values are kept apart and summed in board order,
774
+ whichever thread walked it, so a solve is bitwise the same at every thread count from two up
775
+ (`test/thread-schedule.test.ts`). One thread, and the JavaScript pool at any count, agree with
776
+ that only to floating point: one thread sums inside the walk, in a different association, and
777
+ a JavaScript worker sums its own slice before the totals are summed across workers. Regret
778
+ matching then amplifies
779
+ that rounding, as it does any small change: an action's share follows its regret's sign,
780
+ and where hands are close to indifferent the 32-bit gap grows from iteration to iteration.
781
+ Measured on a small turn (`Ah Kd Qc 8s`, half- and full-pot bets, two raises), 1 and 2
782
+ threads agree on the root strategy to 2e-6 after 12 iterations, differ by up to 6e-2 after
783
+ 50 and by about 1e-2 after 300, by which point each is as exploitable as the other (0.02%
784
+ of pot): where the equilibrium is not unique, the two solves settle on different
785
+ strategies that are equally good. The two engines differ from each other the same way.
786
+
787
+ Exact ties are kept out of this (issue #117). Where a hand's actions are worth the same,
788
+ its regrets are analytically zero, but the node value they are measured against is a
789
+ strategy-weighted sum and comes out an ulp off, by a sign that depends on the summation
790
+ order — and one positive ulp plays an action purely where none plays uniformly. So an
791
+ action value within 2^-20 of the hand's node value, relative to the larger of the two,
792
+ adds exactly zero regret, in both engines: tied actions stay uniform whatever the thread
793
+ count. Without it, a tree with many ties (one river size and no all-in) put 1 and 2 threads
794
+ 3% apart after 12 iterations.
453
795
 
454
796
  The single largest cost is the number of runouts: a river board has one, a turn 48, a flop
455
797
  2,352. Tree width matters nearly as much — a second bet size roughly quadruples the work.
@@ -460,6 +802,618 @@ symmetry: measured, a rainbow flop's stabiliser is trivial and gains **1.00×**,
460
802
  of the conclusion in the parameterised solver alongside this one, where the flop itself is
461
803
  enumerated and can be canonicalised for a 12× win.
462
804
 
805
+ ## Appendix: approximations in detail
806
+
807
+ Each option's own measurements, grouped where options overlap. The
808
+ [goal table](#choosing-an-approximation) and the [options inventory](#options-inventory) summarise
809
+ them, and [docs/APPROXIMATIONS.md](docs/APPROXIMATIONS.md) records what was tried and left out.
810
+
811
+ ### Lite mode (`solveLite`)
812
+
813
+ `solveLite` packages that recipe for a phone or laptop. Give it your own betting. It keeps
814
+ the flop's and reduces the turn and river to one bet (your size nearest 0.75 pot, no raise,
815
+ no shove). It shares river storage between lines that meet (`shareHistories`), buckets
816
+ runouts (`runoutBuckets: 3`) and samples deals (`chanceSampling`), and it stops once the
817
+ root play stops moving. It then re-solves any turn or river at your full betting on demand:
818
+
819
+ ```ts
820
+ import { solveLite } from 'poker-flopsolve';
821
+
822
+ const spot = { board: 'As Kh 7d', pot: 55, stack: 975, oop, ip,
823
+ betSizes: [[0.33, 0.75, 1.5]], raiseSizes: [[0.75]], maxRaises: 3, allowAllIn: true };
824
+ const lite = solveLite(spot, { workers: 4 }); // after enableThreads(4) in a browser
825
+ lite.solution.strategyAt(0, 0); // the flop root
826
+ const turn = lite.resolve(node, board, { player: 0, iterations: 300 });
827
+ ```
828
+
829
+ `lite.changes` says what the blueprint cut from your betting and what it switched on (see
830
+ [The presets](#the-presets)). `litePreset(spot)` returns the blueprint spot, the solve settings and
831
+ that report without solving, for a page that steps its own run; `liteConfig(spot)` returns the spot
832
+ alone. `trackSettle(preset.options.settle)` gives the same stop for such a loop. Lite is a shared blueprint, so it
833
+ never reaches an exploitability target: it plateaus a few percent of the pot from
834
+ equilibrium while its first decisions go on settling (issue #85). `SolveOptions.settle`
835
+ is the stop. Every 20 iterations it reads the average strategy at the root and at in
836
+ position's decision after a check. It stops once both have moved less than 1% of the
837
+ range, by total variation weighted by range, twice in a row. That is two strategy reads,
838
+ with no best-response pass. It works on any solve: `solve(spot, { settle: {} })`.
839
+
840
+ Where the full game fits in memory too, `exploitabilityInExact(lite, exact)` measures Lite's
841
+ play there (issue #154): `exact` is a run of your own spot, solved as far as you like. Each of its
842
+ decisions that Lite also has takes Lite's average strategy, so a size Lite cut is never played,
843
+ and the decisions only reachable through such a size or a raise keep `exact`'s own play. The
844
+ result, % of the pot, is the exploitability of that strategy, with `exact`'s own as its floor.
845
+ It overwrites `exact`'s strategy, so close the run after. The benchmark page's Accuracy box does this
846
+ after a Lite solve, solving Exact to the form's target first.
847
+
848
+ `compressRanges` (issue #156) shrinks both ranges before the blueprint is solved. Each range keeps
849
+ the fewest of its combinations, re-weighted, whose distribution of equity on the flop, on every
850
+ turn and on the river boards stays within a tolerance (default 0.01) of the full range's:
851
+
852
+ ```ts
853
+ const lite = solveLite(spot, { workers: 4, compressRanges: true }); // or { tolerance: 0.02 }, or { size: 150 }
854
+ lite.changes.notes; // [..., 'ranges: compressed to 186 and 180 re-weighted combinations ...']
855
+ ```
856
+
857
+ It is for wide ranges, and off by default. On a button open against a big-blind call (433–518
858
+ weighted combinations a side, issue #47's betting, 4 threads in Node), the compression itself
859
+ taking about 0.05 s (up to three times that where WebAssembly SIMD is missing):
860
+
861
+ | flop | Lite | tolerance 0.01 | tolerance 0.02 | two Lite solves apart |
862
+ |---|---|---|---|---|
863
+ | As Kh 7d | 87.6 s, 706 MiB | 40.6 s, 294 MiB, 186 / 180 combinations, root play 2.7 points off | 31.0 s, 210 MiB, 127 / 128, 2.4 | 2.0 |
864
+ | Ts 9s 4h | 62.1 s, 393 MiB | 31.2 s, 214 MiB, 248 / 268, 1.2 | 25.1 s, 166 MiB, 191 / 204, 1.5 | 1.8 |
865
+ | Ks 9s 4s | 27.3 s, 146 MiB | 16.5 s, 105 MiB, 316 / 372, 2.5 | 13.2 s, 91 MiB, 277 / 319, 2.0 | 3.0 |
866
+
867
+ "Root play off" is the largest difference in how often the range takes an action at the root or
868
+ at in position's decision after a check, against Lite on the full ranges; the last column is the
869
+ same between two Lite solves of the full ranges, one stopped at half the settle tolerance. On
870
+ the narrow bench ranges (about 200 combinations) it gains little, and on the monotone flop it
871
+ loses: As Kh 7d settled in 16.0 s against 21.5 (135 MiB against 173), Ts 9s 4h in 8.6 against 12.7 (91 against 122), and Ks 9s 4s in 7.8 against 6.6 (57 against 47). Dropping
872
+ combinations breaks the suit and rank symmetries that fold boards together, so where those were
873
+ saving the most there is the least to gain (`bench/range-compress`).
874
+
875
+ What it keeps is how the range plays. What it does not keep is what one combination does: the
876
+ blueprint, and `resolve`, hold a strategy only for the combinations kept, each carrying the
877
+ weight of those dropped, and `exploitabilityInExact` covers only those: a combination left out
878
+ keeps `exact`'s play. `compressRanges(spot)` gives the two compressed ranges on their own.
879
+ `minWeight` is applied to the ranges as given, before compressing.
880
+
881
+ Measured on that spot's betting, in headless Chromium. The time counts solving and the settle
882
+ checks. Root play loss is what OOP's root mix and IP's mix after a check lose at the
883
+ unshared blueprint's per-action values (solved to 0.05% of pot), with that blueprint's
884
+ own loss as the floor. It measures what sharing, sampling and the early stop cost.
885
+ Re-solve gain is an opponent's best response to a turn re-solved at the full betting
886
+ (300 iterations), under the unshared blueprint's ranges, % of the subgame pot, weighted
887
+ by how often each turn is reached:
888
+
889
+ | flop | settled, 1 / 2 / 4 threads | peak memory | root play loss, % pot (floor) | re-solve gain, % (unshared) | a re-solve, 1 / 2 / 4 threads |
890
+ |---|---|---|---|---|---|
891
+ | As Kh 7d | 103 / 59 / 35 s | 511 MiB | 0.023 / 0.014 (0.009 / 0.008) | 3.1 / 2.7 (0.67 / 0.50) | 38 / 22 / 14 s |
892
+ | Ts 9s 4h | 64 / 38 / 21 s | 426 MiB | 0.118 / 0.076 (0.116 / 0.052) | 4.0 / 3.3 (0.48 / 0.55) | 42 / 23 / 13 s |
893
+ | Ks 9s 4s | 31 / 19 / 12 s | 253 MiB | 0.059 / 0.037 (0.047 / 0.025) | 3.6 / 3.6 (0.44 / 0.47) | 28 / 17 / 10 s |
894
+
895
+ Peak memory includes a re-solve. Against exact solves of the full game:
896
+ - **Issue #51's T₀ on As Kh 7d** (three sizes and a shove on every street): OOP's root
897
+ play lost 0.072% of pot at T₀'s values. The same simplified tree, unshared and
898
+ converged, lost 0.057, so most of the cost is the simplification.
899
+ - **Eight of napkinpoker's postflop-solver spots** (real weighted ranges, SRP and 3-bet
900
+ pots): root play lost 0.034 / 0.135% of pot on average, against 0.027 / 0.131 for the
901
+ stored solves' own play, settling in 38–176 s on one thread. Wide single-raised ranges
902
+ needed up to 452 MiB of storage, near a browser's default `maxBytes` of 512. For more
903
+ headroom add `compactStorage` and `wasmStorage`: 300 MiB on rainbow, 27% slower.
904
+
905
+ `laterRaise: true` keeps a turn and river raise: 1.74 times the time and 546 MiB.
906
+ `noDonk` and `flopMaxRaises: 2` save 44% an iteration together, but on Ts 9s 4h they
907
+ quadrupled the re-solve gain. So they are off unless asked for.
908
+
909
+ **Better turn re-solves: `keepBudget`.** It keeps the most-reached flop lines unshared, as
910
+ many as a storage budget allows (issue #113; see [History sharing](#history-sharing)).
911
+ The lines are ranked on a short solve of the blueprint with its river checked down
912
+ (`checkedDown`), and the blueprint is solved with them kept. `litePreset` runs that
913
+ ranking too, and `keepWithin` does it alone:
914
+
915
+ ```ts
916
+ import { wasmStorage } from 'poker-flopsolve/wasm-storage';
917
+
918
+ const lite = solveLite(spot, { workers: 4, keepBudget: 150 * 2 ** 20, precision: 'i16', wasmStorage });
919
+ lite.kept; // ['check check /', 'bet 18.15 call /', 'bet 82.5 call /'] on As Kh 7d
920
+ ```
921
+
922
+ With a budget the solve also stops later: `settle`'s tolerance is 0.005, not 0.01 (issue #123),
923
+ as the ranges the kept lines bring to the turn go on improving after the root play settles.
924
+ Measured the same way on 4 threads, the ranking included in the time:
925
+
926
+ | flop | kept | settled, Chromium | peak memory | root play loss, % pot | re-solve gain, % | at tolerance 0.01 |
927
+ |---|---|---|---|---|---|---|
928
+ | As Kh 7d | 3 lines | 580 it, 45 s | 534 MiB | 0.022 / 0.008 | 1.8 / 1.4 | 35 s; 2.5 / 1.7 |
929
+ | Ts 9s 4h | 6 lines | 440 it, 29 s | 467 MiB | 0.104 / 0.047 | 1.5 / 1.2 | 22 s; 1.8 / 1.2 |
930
+ | Ks 9s 4s | all 19 | 460 it, 13 s | 315 MiB | 0.056 / 0.031 | 1.8 / 1.2 | 11 s; 2.5 / 1.9 |
931
+
932
+ The root play is unchanged, and keeping lines cuts the re-solve gain by a third to a half; the
933
+ later stop takes off 15–28% more for out of position (3–34% in position) for 16–32% more time. What is left is still the
934
+ stop: the root settles before the ranges reaching the turn do. A stop that also watched the kept
935
+ lines' turn ranges did no better than a tighter root tolerance; `settle: { tolerance: 0.0035 }`
936
+ re-solves at 1.6 / 1.3, 1.4 / 1.2 and 1.5 / 1.0 for 39–51% more time than 0.01. Run longer with
937
+ `settle: false, iterations: 800`: As Kh 7d then re-solves at 1.3 / 1.1 in 59 s on 4 threads
938
+ (533 MiB), where plain sharing gives 2.2 / 2.4.
939
+ `bench/lite/` has the scripts and logs.
940
+
941
+ ### Fitting a large tree (`largeTree`)
942
+
943
+ `largeTree` from `poker-flopsolve/wasm-storage` returns the combination of memory levers
944
+ that measured best on the round's target T (As Kh 7d, three sizes, a 0.75 raise and all-in,
945
+ three aggressions, every street; 17.2 GiB at 32 bits): `thinSizes`, 16-bit storage on the
946
+ WebAssembly engine and chance sampling.
947
+
948
+ ```ts
949
+ import { createRun, defineSpot } from 'poker-flopsolve';
950
+ import { largeTree } from 'poker-flopsolve/wasm-storage';
951
+
952
+ const { config, options } = largeTree(
953
+ { ...myConfig, maxBytes: 2.5 * 2 ** 30 }, // the browser build's default, 512 MiB, is too little
954
+ { options: { workers: 4 } }, // solve options of your own, merged; storage: 'compact' for less memory
955
+ );
956
+ const run = createRun(defineSpot(config), options);
957
+ ```
958
+
959
+ Issue #102 measured each combination on T, Node, 4 threads, against `thinSizes` alone at
960
+ 32 bits solved for 600 iterations (0.154% of pot). Loss is what the root play gives up at the
961
+ reference's per-action EVs, OOP at the root / IP after a check, % of pot. The reference's
962
+ own unconverged mix loses 0.032 / 0.019 at its own values, so that is the floor. "Settled"
963
+ is when OOP's loss comes within 0.02% of pot of its final value. EV error is per hand at the
964
+ root, mean.
965
+
966
+ | Combination | Storage | Peak, Node / Chromium | s/iteration, Node / Chromium | Settled | Loss at the end | EV error |
967
+ |---|---|---|---|---|---|---|
968
+ | `thinSizes`, 16-bit | 1.47 GiB | 1.75 / 1.65 GiB | 1.56 / 1.48 | 317 s | 0.031 / 0.020 | 0.04 / 0.02 |
969
+ | `thinSizes`, compact | 1.02 GiB | 1.28 / 1.20 GiB | 1.95 / 1.89 | 396 s | 0.033 / 0.020 | 0.03 / 0.06 |
970
+ | **`thinSizes`, 16-bit, sampling (`largeTree`)** | 1.47 GiB | 1.97 / 1.87 GiB | 0.25 / 0.23 | **155 s** | 0.031 / 0.020 | 0.05 / 0.05 |
971
+ | `thinSizes`, compact, sampling (`storage: 'compact'`) | 1.02 GiB | 1.48 / 1.42 GiB | 0.28 / 0.27 | 168 s | 0.031 / 0.020 | 0.05 / 0.09 |
972
+ | `thinSizes`, 16-bit, sampling, `runoutBuckets: 3` | 0.86 GiB | 1.25 / 1.14 GiB | 0.14 / 0.14 | 87 s | 0.031 / 0.020 | 0.20 / 0.17 |
973
+ | `thinSizes`, 16-bit, `shareHistories` | 0.42 GiB | 0.69 GiB | 1.70 | 525 s | 0.048 / 0.019 | 0.51 / 0.48 |
974
+
975
+ So 16-bit or compact storage and sampling cost the root nothing over the thinned tree, and
976
+ sampling makes it 2.5 times faster. Buckets halve the time again for a per-hand error of
977
+ 0.2% of pot on average and 2.3% at worst. Sharing on top saves memory but loses more and is
978
+ no faster. What `thinSizes` itself costs, against the full tree, was measured on T₀ against
979
+ an exact solve: 0.04% of pot of root play and 1.5% of pot of per-hand EV. On seven of
980
+ napkinpoker's spots (#87), against postflop-solver's EVs, the preset's root play lost as
981
+ little as an exact solve's at OOP's root (0.04% of pot) but 0.34% against 0.16% for IP after
982
+ a check, where `thinSizes` cuts the 0.33 bet. `bench/combos/` has the scripts and every run.
983
+
984
+ #### Thinning bet sizes (`thinSizes`)
985
+
986
+ `thinSizes: true` keeps the configured sizes only where they earn their memory. The root
987
+ keeps every size. Every other decision keeps the one bet, raise or shove nearest 0.75 of
988
+ the pot, or a shove where that size would be one. A river opening bet after an earlier
989
+ street saw a bet also keeps sizes above the pot and the shove. A tree's memory is almost
990
+ all on the river, and each flop or turn size multiplies the river subtrees below it. This
991
+ rule cuts most of them. It is the shape that growing sizes one at a time by value per
992
+ byte arrived at (issue #51), applied as a fixed rule. It costs nothing to build, and
993
+ unset, the tree is unchanged.
994
+
995
+ It changes the game. A thinned tree is a smaller game, solved exactly within itself, and
996
+ its strategy has no answer to the sizes that were cut. Measured on bench ranges, pot 55,
997
+ stack 975, sizes 0.33 / 0.75 / 1.5 with a shove. The reference is the full tree with
998
+ shove-only raises and 2 aggressions (T₀), solved exactly to 0.23% of pot. Root EVs per
999
+ combination, % of pot, OOP / IP:
1000
+
1001
+ | Tree | Storage, f32 | Root EV error, mean / max | Root size agrees |
1002
+ |---|---|---|---|
1003
+ | As Kh 7d, T₀ exact | 5.78 GiB | — | — |
1004
+ | `thinSizes` | 1.30 GiB | 1.45 / 1.74, max 5.6 / 6.3 | 83% |
1005
+ | The issue's rule: 3 sizes on flop and turn opening bets, 1 elsewhere | 1.97 GiB | 1.59 / 1.34, max 13.5 / 5.1 | 76% |
1006
+ | One size everywhere (0.75, shove facing a bet) | 0.39 GiB | 4.41 / 6.58, max 29 / 65 | — |
1007
+ | Ks 9s 4s, T₀ exact | 1.26 GiB | — | — |
1008
+ | `thinSizes` | 0.29 GiB | 2.10 / 1.90, max 6.2 / 5.9 | 96% |
1009
+ | 3 sizes on flop opening bets, 1 elsewhere | 0.19 GiB | 1.47 / 1.64, max 4.2 / 5.8 | 70% |
1010
+ | The issue's rule | 0.43 GiB | 1.33 / 1.15, max 3.3 / 6.7 | 89% |
1011
+ | Ks 9s 4s, T exact (0.75 raise, 3 aggressions) | 3.75 GiB | — | — |
1012
+ | `thinSizes` | 0.64 GiB | 1.26 / 1.01, max 4.4 / 2.1 | 100% |
1013
+
1014
+ "Root size agrees" is the share of OOP's range whose best root bet size by EV is the same
1015
+ as in the exact solve. The max is over combinations weighing at least 1%. On As Kh 7d the
1016
+ rule is the most accurate per byte measured: two thirds of the issue's rule's memory, and
1017
+ less than half its worst error. On Ks 9s 4s, where the flop's in-position sizes matter
1018
+ more, three flop sizes alone did better for less. Peak memory in Node is the tree's: 1.41
1019
+ GiB for the first, 0.76 GiB for Ks 9s 4s T.
1020
+
1021
+ In headless Chromium (WebAssembly engine), an iteration of the thinned As Kh 7d T₀ takes
1022
+ 1.9 s on one thread and 0.89 s on four; Ks 9s 4s T₀ 0.66 s and 0.30 s; Ks 9s 4s T 1.44 s
1023
+ and 0.64 s. Each reached about 0.2% of pot in 331 iterations, so a solve takes about 11, 4
1024
+ and 8 minutes on one thread, and 5, 2 and 3.5 on four.
1025
+
1026
+ The growth itself is not offered. It found the shape, and grown trees were more accurate
1027
+ again (1.0 / 1.2% mean, 3.9% max, 90% agreement in 1.7 GiB on As Kh 7d). But each round
1028
+ probes candidate sizes in a second tree beside the current one, which took 4.8 to 8.7 GiB
1029
+ and 30 to 40 minutes. On Ks 9s 4s, starting from one size, it never added the flop sizes
1030
+ it needed and ended worse than the fixed rule.
1031
+
1032
+ It combines with `shareHistories`, which shares the river storage of lines that meet:
1033
+ the target tree of issue #51, As Kh 7d with a 0.75 raise and 3 aggressions (T), is 17.2 GiB
1034
+ at 32 bits, 2.9 GiB thinned, and 0.85 GiB thinned and shared (Ks 9s 4s: 3.75, 0.64, 0.19).
1035
+ Issue #102 measured the pair. Thinned and shared, As Kh 7d T₀ stalls at about 4.4% of pot
1036
+ exploitability, against 0.2% thinned alone; that is sharing's own floor (shared alone, T₀
1037
+ sits at 8%), not a bug. The root play barely notices: it loses 0.052% of pot at the exact
1038
+ solve's values against 0.038% thinned alone. But once thinned T fits at 16 bits, sharing
1039
+ on top buys memory only, at more loss and no speed; see the preset below.
1040
+
1041
+ ### History sharing
1042
+
1043
+ `shareHistories: true` keeps one set of river regrets and strategy sums for every betting
1044
+ line that reaches the river with the same pot. With pot-fraction sizes many lines meet:
1045
+ check, bet, call and bet, call, and every raise line taken in either order. Their river
1046
+ subtrees are identical, so their nodes can share storage. Each line is still walked with
1047
+ its own reach, so an iteration costs what it did; only storage shrinks. Off by default.
1048
+
1049
+ It is lossy. A player plays one river strategy for every line that met, though each line
1050
+ brings different ranges. The strategy is still one for the whole game, so
1051
+ `exploitabilityPercent()` measures it exactly. Each line's regret is weighted by how often
1052
+ the hand plays into it, which cost four times less than plain CFR's sum. Bench ranges, As Kh 7d, pot 55, stack 975, 4 threads, root EVs
1053
+ against the exact solve:
1054
+
1055
+ | Tree | Storage, f32 | Exploitability | Root EV error, mean / max | Iterations |
1056
+ |---|---|---|---|---|
1057
+ | 3 sizes, all-in raise, 2 aggressions (exact: 0.28%) | 5.8 GiB → 1.22 GiB | 8.0% of pot | 0.72% / 2.5% of pot | 400 |
1058
+ | 2 sizes, all-in raise, 2 aggressions (exact: 0.25%) | 1.93 GiB → 0.48 GiB | 5.8% of pot | 0.94% / 2.4% of pot | 400 |
1059
+ | 1 size, all-in raise, 2 aggressions (exact: 0.25%) | 0.39 GiB → 0.14 GiB | 4.0% of pot | 0.67% / 6.8% of pot | 300 |
1060
+
1061
+ On the two-size tree, out of position's EV at each root action was off by 1.7% of pot on
1062
+ average, and 85% of the range still picked the same bet size as the exact solve (70%
1063
+ with plain CFR's sum, which was left 24% of pot exploitable).
1064
+
1065
+ On the three-size tree with a 75% raise and three aggressions, which does not fit
1066
+ otherwise, 173 river starts collapse to 23: 17.2 GiB becomes 2.9 GiB at 32 bits, and
1067
+ 8.7 GiB becomes 1.5 GiB at 16. In Node at 16 bits the whole process peaked at 1.6 GiB
1068
+ on one thread (about 100 s an iteration) and 2.0 GiB on four (30 s an iteration), and the
1069
+ strategy was 27% of pot exploitable after 50 iterations, 15% after 100 and 12% after 150. At 32 bits it runs on the
1070
+ WebAssembly engine in 10.4 s an iteration on four threads, peaking at 3.2 GiB. An
1071
+ iteration costs what the unshared tree's would, so this makes the spot fit, not fast.
1072
+ Expect a strategy several percent of the pot from equilibrium, with EVs about 1% off on
1073
+ average, in a spot that would not otherwise fit. Sharing the turn too, and merging subtrees
1074
+ by stack-to-pot ratio, were measured and dropped (see [docs/APPROXIMATIONS.md](docs/APPROXIMATIONS.md)).
1075
+ A shared spot can warm-start only from another shared solve.
1076
+
1077
+ **Keeping the busiest lines unshared.** A turn re-solved from a shared blueprint
1078
+ (`resolveSubgame`) inherits only the ranges the blueprint brings to it, and sharing
1079
+ distorts them. The flop play is stored unshared, but it learns from shared river values.
1080
+ `shareHistories: { keepLines }` gives the named lines (as `Solution.path` names their
1081
+ first turn decision, e.g. `"check check /"`) storage of their own. `linesWithin` picks the
1082
+ most-reached lines that a storage budget allows. Rank them on a cheap copy of the spot,
1083
+ with its river checked down, then solve the hybrid from cold:
1084
+
1085
+ ```ts
1086
+ import { createRun, defineSpot, linesWithin } from 'poker-flopsolve';
1087
+ import { wasmStorage } from 'poker-flopsolve/wasm-storage';
1088
+
1089
+ const blueprint = { ...config, shareHistories: true };
1090
+ const pick = createRun(defineSpot({ ...blueprint, betSizes: [flopSizes, turnSizes, []] }), { workers: 4 });
1091
+ pick.step(80);
1092
+ const keepLines = linesWithin(pick.snapshot(), 150 * 2 ** 20, { config: blueprint, precision: 'i16' });
1093
+ pick.close();
1094
+ const run = createRun(defineSpot({ ...blueprint, shareHistories: { keepLines } }), { workers: 4, precision: 'i16', wasmStorage });
1095
+ ```
1096
+
1097
+ On issue #47's blueprint (one turn and river size, `runoutBuckets: 3`), turns re-solved
1098
+ from plain sharing gave a best response 3.0–4.2% of the subgame pot, against 0.4–0.7% from
1099
+ the unshared blueprint. With the budget, the gap was 0.1–0.8%. On As Kh 7d, the 150 MiB
1100
+ budget at 16 bits kept 3 lines and peaked at 392 MiB in Chromium on 4 threads, with a
1101
+ re-solve gain of 1.47 / 0.92% against 0.67 / 0.50% unshared. Figures are in
1102
+ `bench/blueprint-share/README.md`.
1103
+
1104
+ ### Chance sampling
1105
+
1106
+ `approximations: { chanceSampling: {} }` walks each turn and river deal on only some
1107
+ training iterations, with probability `p` (default 0.35). A deal left out stands in with
1108
+ the per-hand values it returned the last time it was walked. A walked deal adds
1109
+ `b + (v − b) / p`, its baseline corrected by how far its values moved (VR-MCCFR,
1110
+ Schmid et al. 2019). Iterations get several times cheaper, convergence per iteration
1111
+ loses less than that, and exploitability is still measured exactly in the full game.
1112
+ Single-threaded, Node, time to 0.3% of pot:
1113
+
1114
+ | Flop | Exact | Sampled | Baselines |
1115
+ |---|---|---|---|
1116
+ | AsKh7d, bench ranges, pot 100 | 23.7 s | 15.9 s | 29 MB |
1117
+ | Ks9s4s, bench ranges, pot 100 | 6.0 s | 4.3 s | 6 MB |
1118
+ | AsKh7d, bench ranges, pot 60 (wide) | 13.4 s | 9.3 s | 29 MB |
1119
+ | AsKh7d, pairs and broadway | 16.7 s | 12.9 s | 31 MB |
1120
+ | Ks9s4s, pairs and broadway | 5.5 s | 4.5 s | 7 MB |
1121
+
1122
+ Stopped at 15 s, single-threaded in Chromium, it leaves 0.29% of pot on the first spot
1123
+ where the exact solve leaves 0.69%, 0.11% for 0.20% on the wide flop and 0.17% for
1124
+ 0.28% on pairs and broadway; the range-weighted error of per-hand root EVs against an
1125
+ exact 0.1% solve falls from 1.0–1.1% of pot to 0.12–0.16% on the first, and to about a
1126
+ third on the others. It runs on `workers` threads wherever the engine threads (issue #99:
1127
+ the WebAssembly engine in Node and the browser, the JavaScript engine in Node). Each thread
1128
+ samples the deals of its own runouts, and whether a deal is walked on an iteration is a hash
1129
+ of its chance node, the deal and the iteration, so every thread count walks the same deals
1130
+ and a fixed count is bitwise repeatable. On 4 Chromium threads it ran 3.1–3.2× faster than on
1131
+ one (`bench/blueprint-share/README.md`). The baselines count against `maxBytes`: with `precision` unset, a spot whose 32-bit
1132
+ storage fits but not beside its baselines is solved at 16 bits (issue #139; on the JavaScript
1133
+ engine unless the solve passes `wasmStorage`), and an explicit `precision` that does not fit
1134
+ throws. With `p: 1` it is the exact solve, bit for bit. `rounds: [2]` samples
1135
+ river deals only. It works over any storage: 32 or 16 bits (since issue #102) or compact.
1136
+
1137
+ ### Storage: 16-bit and compact
1138
+
1139
+ Two ways to store regrets and strategy sums in less memory, and the engine that runs both on WebAssembly.
1140
+
1141
+ #### 16-bit storage
1142
+
1143
+ A spot too big for 32-bit storage under `maxBytes` is solved at 16 bits instead
1144
+ (`precision: 'i16'` forces it). Regrets and strategy sums are stored as 16-bit integers with
1145
+ one scale per node and board, about halving memory. `estimate.compressedBytes` reports
1146
+ that size, and a spot is refused only if even that exceeds `maxBytes`. Measured on AsKh7d:
1147
+
1148
+ | Flop | Ranges | 32-bit | 16-bit |
1149
+ |---|---|---|---|
1150
+ | 1 size, 1 raise | 198 vs 165 | 150 MB | 85 MB |
1151
+ | 2 sizes, 1 raise | 198 vs 165 | 824 MB | 425 MB |
1152
+ | 2 sizes, 1 raise | 309 vs 424 | 1,645 MB | 836 MB |
1153
+ | 2 sizes, 2 raises | 309 vs 424 | 3,344 MB | 1,689 MB |
1154
+
1155
+ The 309 vs 424, two-size flop solved with two threads at a peak RSS of about 1.1 GB, so it
1156
+ fits a 2 GB machine. It reaches each accuracy target in the same number of iterations as
1157
+ 32-bit, but each iteration costs about 15–20% more, because every update re-encodes its
1158
+ block. Strategy sums round up or down at random, weighted by the remainder: rounded to
1159
+ nearest, small sums lose most of each iteration's contribution and exploitability stalls
1160
+ near 0.04% of pot. The randomness is a hash of the slot and iteration, so solves stay
1161
+ deterministic at any thread count.
1162
+
1163
+ #### 16-bit and compact storage on the WebAssembly engine
1164
+
1165
+ ```ts
1166
+ import { createRun, defineSpot } from 'poker-flopsolve';
1167
+ import { wasmStorage } from 'poker-flopsolve/wasm-storage';
1168
+
1169
+ const run = createRun(defineSpot(config), { precision: 'i16', wasmStorage, workers: threads });
1170
+ // or a spot with `compactStorage: {}`, with the same `wasmStorage`
1171
+ ```
1172
+
1173
+ A second build of the engine keeps 16-bit storage and every `compactStorage` mode as the
1174
+ JavaScript engine does, update for update: per-block scales, rounding to nearest for 16-bit
1175
+ regrets, the same hash for the random rounding, per-hand power-of-two scales, `sums: false`,
1176
+ `blockScale`, chance sampling's catch-up. It works in 32-bit floats, four hands to a SIMD
1177
+ vector, where JavaScript works in 64-bit, so a stored value differs from JavaScript's only
1178
+ where it lies within float32 precision of a rounding boundary (about 0.5% of 16-bit values
1179
+ an iteration, 0.01% of compact ones); the solves converge alike. Threads share its memory
1180
+ as they do the default engine's. Only `poker-flopsolve/wasm-storage` carries its bytes, so
1181
+ without the import a build is unchanged, and a solve that does not pass it gives the same
1182
+ results as before.
1183
+
1184
+ Issue #47's blueprint (flop betting kept, one turn and river size, `runoutBuckets: 3`) solved
1185
+ to 0.3% of pot in headless Chromium on a 4-core container, which ran the monotone f32 blueprint
1186
+ about 1.3 times slower than the machine above (`bench/nested/wasm-storage.ts`); peak is the
1187
+ tab's resident memory:
1188
+
1189
+ | As Kh 7d | storage | peak | 4 threads | 1 thread | turn re-solve, 4 / 1 threads |
1190
+ |---|---|---|---|---|---|
1191
+ | f32 | 707 MiB | 985 MiB (902) | 106 s, 280 it | 303 s | 8.5 / 29.6 s, 64 MiB |
1192
+ | i16, `wasmStorage` | 363 MiB | 577 MiB (526 on 1 thread) | 86 s, 200 it | 288 s | 10.6 / 36.0 s, 32 MiB |
1193
+ | compact, `wasmStorage` | 272 MiB | 462 MiB (427) | 106 s, 200 it | 435 s | 12.2 / 40.7 s, 21 MiB |
1194
+
1195
+ | Ks 9s 4s | storage | peak | 4 threads | 1 thread | turn re-solve, 4 / 1 threads |
1196
+ |---|---|---|---|---|---|
1197
+ | f32 | 187 MiB | 394 MiB (346) | 32.5 s, 240 it | 104 s | 7.3 / 21.5 s, 40 MiB |
1198
+ | i16, `wasmStorage` | 97 MiB | 264 MiB (236) | 23.8 s, 160 it | 119 s | 7.0 / 23.8 s, 20 MiB |
1199
+ | compact, `wasmStorage` | 73 MiB | 223 MiB (205) | 35.1 s, 200 it | 119 s | 8.6 / 30.0 s, 14 MiB |
1200
+
1201
+ An iteration costs 1.1–1.15 times f32's at 16 bits and 1.3–1.4 times compact, and the
1202
+ quantised solves often reach the target a check sooner, so the rainbow blueprint at i16 is
1203
+ faster than at f32 in 0.58 times its peak memory. The i16 blueprint on the JavaScript engine
1204
+ took 190 s on one thread or four on monotone. On the bench `flop` spot, to 0.2% of pot
1205
+ (peak): f32 28.5 s on one thread and 9.2 s on four (708 MiB), i16 33.3 s and 10.9 s
1206
+ (293 MiB), compact 41.6 s and 12.6 s (265 MiB), and i16 on the JavaScript engine 80 s and
1207
+ 81 s.
1208
+
1209
+ Issue #84's pass mark for a phone, the rainbow blueprint at 512 MiB peak or less in 60 s or
1210
+ less on four threads, is half met: compact peaks at 462 MiB but takes 106 s, and i16 takes
1211
+ 86 s at 577 MiB. Even f32 takes 106 s here; scaled by the 1.3 above, i16 would take about
1212
+ 66 s on the machine #47 measured.
1213
+
1214
+ WebAssembly memory is one buffer, but Chromium lets it reach wasm32's whole 4 GiB, plain or
1215
+ shared, created at that size or grown to it, while it refuses any ArrayBuffer over 2 GiB less
1216
+ 2 MiB (Chromium 153, `bin/memory-ceiling.ts`). So the engine's ceiling is 4 GiB in a tab, as
1217
+ in Node, and compact storage needs no chunks of its own there.
1218
+
1219
+ #### Compact storage
1220
+
1221
+ `compactStorage: {}` in the spot's config stores regrets and strategy sums as 8-bit
1222
+ integers, each hand on each board scaled by its own power of two. Regret matching and the
1223
+ average strategy divide each hand's values by their own total, so the scale cancels
1224
+ wherever a strategy is read, and costs a byte per hand. Values round up or down at random,
1225
+ weighted by the remainder, as 16-bit sums do. It is set on the spot rather than the solve,
1226
+ because `maxBytes` is checked against it when the spot is defined
1227
+ (`estimate.compactBytes`).
1228
+
1229
+ `compactStorage: { sums: false }` keeps no strategy sums. Each node then plays the current
1230
+ profile, the regret-matched strategy the next iteration would play. It is cheaper again but
1231
+ much more exploitable on deep trees. `blockScale: true` takes the per-hand byte away too.
1232
+
1233
+ Storage and peak memory on issue #20's target spots (AsKh7d and Ks9s4s, pot 55, stack 975,
1234
+ three bet sizes, a 75% raise, three aggressions), measured on four threads in Node:
1235
+
1236
+ | Storage | Bytes per slot | T | Monotone T |
1237
+ |---|---|---|---|
1238
+ | 32-bit | 8.0 | 17.2 GiB | 3.75 GiB |
1239
+ | 16-bit | 4.0 | 8.7 GiB | 1.90 GiB |
1240
+ | compact | 2.75 | 5.9 GiB (peak 6.4 GB), 35 s an iteration | 1.29 GiB (peak 1.7 GB) |
1241
+ | compact, `sums: false, blockScale: true` | 1.03 | 2.2 GiB (peak 2.7 GB), 24 s an iteration | 0.48 GiB (peak 0.8 GB) |
1242
+
1243
+ Accuracy at 320 iterations, against reference solves to 0.17% of pot (T₀: AsKh7d, three
1244
+ sizes, all-in as the only raise) and 0.22% (the same tree on Ks9s4s). Exploitability is
1245
+ true, in the full tree; EV error is per combination at the root, range-weighted, in % of pot;
1246
+ "same size" is the share of OOP's hands, among those whose best root bet size beats the
1247
+ next by 0.5% of pot in the reference, that still prefer it:
1248
+
1249
+ | Storage | T₀: exploitability, EV error, same size | Monotone T₀ |
1250
+ |---|---|---|
1251
+ | 32-bit | 0.69% (the reference run itself) | 0.71%, 1.19%, 100% |
1252
+ | compact | 0.81%, 0.23%, 100% | 0.83%, 1.09%, 100% |
1253
+ | compact, `sums: false, blockScale: true`, CFR+ | 4.76%, 0.17%, 78% | 4.08%, 1.28%, 62% |
1254
+
1255
+ It combines with `shareHistories` (one set of storage for betting lines that reach the same
1256
+ pot), and the pair is what brings T under 2 GiB: 0.99 GiB with sums, peaking at 1.5 GB on four
1257
+ threads, and 0.37 GiB with `sums: false, blockScale: true`. Sharing is lossy on its own; on
1258
+ T₀ at 160 iterations it was 9.5% of pot exploitable in 1.06 GiB at 32 bits, with root EVs
1259
+ 0.66% of pot off and 97% of clear bet-size choices kept; with compact storage added, 9.0%,
1260
+ 0.63% and 100%, in 0.36 GiB.
1261
+
1262
+ It runs on the JavaScript engine, like 16-bit storage, on Node worker threads but on one
1263
+ thread in the browser, unless the solve passes `wasmStorage` (see the WebAssembly engine),
1264
+ which runs it on the WebAssembly engine, threads included. It combines with `precision`
1265
+ (for the rounds before `from`), warm starts and coarse starts (read and written compactly,
1266
+ rounded to nearest), `runoutBuckets` and chance sampling; only `analysisOnly` is refused.
1267
+ In headless Chromium on one thread, on the JavaScript engine, monotone T₀ took 10.1 s an
1268
+ iteration compact, 8.1 s at 16 bits and 2.3 s at 32 bits on WebAssembly; T itself, at
1269
+ `sums: false, blockScale: true`, allocated its 2.2 GiB and ran at 95 s an iteration. Storage is split into buffers under 1 GiB, because Chromium refuses
1270
+ an ArrayBuffer of 2 GiB or more. `bench/storage/` has the measurements and the variants
1271
+ that were left out: 4- and 6-bit regrets, a log scale, sparse regrets, and dropping sums on
1272
+ the later streets only.
1273
+
1274
+ ### Runout buckets and coarse start
1275
+
1276
+ Both fold turn and river cards that play alike. `runoutBuckets` solves the folded game. `coarseStart`
1277
+ only starts from it and then solves the real game, so with `runoutBuckets` at its own gap or wider it
1278
+ has nothing left to fold and does nothing. On ranges with no rank symmetry, such as all of napkinpoker's
1279
+ weighted ranges, neither folds anything.
1280
+
1281
+ #### Runout buckets
1282
+
1283
+ `runoutBuckets: true` solves one turn or river card for several that play alike: two cards
1284
+ of one suit, neither pairing the board, equally connected to its straights, whose rank
1285
+ swap maps both ranges onto themselves. The stored card stands for the others with hands
1286
+ relabelled by the swap. A number instead of `true` is the widest rank gap allowed in a
1287
+ bucket (`true` is 1, the most cautious).
1288
+
1289
+ It is an approximation — 55 on a 6 river and 66 on a 5 river sit on opposite sides of the
1290
+ board card, and no relabelling fixes that — so `exploitabilityPercent()` (and
1291
+ `targetPercent`) measure the bucketed game, and `run.trueExploitabilityPercent()` measures
1292
+ the strategy in the real one, every card dealt. How much it saves and costs depends on
1293
+ the ranges; suited connectors keep ranks apart, pocket pairs near the merged ranks cost
1294
+ accuracy. Ranges weighted hand by hand rarely allow any swap: on all 70 of napkinpoker's
1295
+ realistic spots it folds nothing, at any gap (see
1296
+ [Every option on napkinpoker's reference solves](#every-option-on-napkinpokers-reference-solves)). On AhKdQc, 4 threads, to 0.3% of pot in the bucketed game:
1297
+
1298
+ | Ranges | Gap | Runouts | Time | True exploitability |
1299
+ |---|---|---|---|---|
1300
+ | Bench (wide, connectors) | exact | 2,352 | 13.2 s | 0.271% |
1301
+ | | 1 | 1,672 | 10.5 s | 0.278% |
1302
+ | | 3 | 1,348 | 8.0 s | 0.302% |
1303
+ | Pairs and broadway | exact | 2,352 | 9.3 s | 0.228% |
1304
+ | | 1 | 1,396 | 4.9 s | 0.482% |
1305
+ | | 3 | 1,088 | 4.2 s | 0.542% |
1306
+
1307
+ #### Coarse start
1308
+
1309
+ `approximations: { coarseStart: { iterations: 40 } }` first solves a coarse copy of the
1310
+ spot, with runouts bucketed as by `runoutBuckets: 3`, for that many iterations. It then
1311
+ starts the real spot from those regrets. Coarse iterations are cheaper, and the real solve
1312
+ picks up roughly where they left off. The answer is still the real spot's, and
1313
+ exploitability measures the real game. Off by default. Both runs are in memory at the
1314
+ switch and count against `maxBytes`: with `precision` unset, a spot whose 32-bit storage
1315
+ leaves no room for the coarse run is solved at 16 bits, the coarse run too (issue #148; on
1316
+ the JavaScript engine unless the solve passes `wasmStorage`), and one that does not fit
1317
+ even so throws.
1318
+
1319
+ Measured in Chromium on one thread, stopped at 15 s, 40 coarse iterations, with root-EV
1320
+ error per combination (range-weighted mean, % of pot) against a 0.1% reference:
1321
+
1322
+ | Flop | Cold | Coarse start | Exploitability, cold → coarse start |
1323
+ |---|---|---|---|
1324
+ | AsKh7d, compare ranges, 50% bet | 1.51% | 0.19% | 0.94% → 0.40% |
1325
+ | AsKh7d, bench ranges, 66% bet | 0.26% | 0.06% | 0.24% → 0.15% |
1326
+ | Ks9s4s, monotone | 0.04% | 0.11% | 0.10% → 0.07% |
1327
+
1328
+ The monotone flop reaches 0.5% error in half the time, but a cold solve has already settled
1329
+ it by 15 s. To an exploitability target in Node, coarse start was faster on all three.
1330
+ `bench/coarse-to-fine/` has the harness.
1331
+
1332
+ ### Every option on napkinpoker's reference solves
1333
+
1334
+ `bench/reference/` scores any solution against 70 full-hand solves by postflop-solver
1335
+ (every flop texture, realistic weighted ranges; see its `napkinpoker/README.md`). The fixtures are
1336
+ private and not in this repository (issue #119): `bench/reference/napkinpoker.ts` reads them from
1337
+ `NAPKIN_REFERENCE` or a napkinpoker checkout beside this one. Only aggregate scores are published here. At each
1338
+ stored flop node, and the first turn decision after each stored turn card, it values our
1339
+ strategy at the stored per-action EVs. Those are exact action against action. The EV our
1340
+ play gives up against each hand's best stored action is the regret we leave in that game.
1341
+ It is reach-weighted by the stored range, in % of the node's pot. A flop node is scored
1342
+ when the opponent reaches it at least 3% of the time. A turn node is scored when both
1343
+ players play its flop line at least 3% of the time. The stored strategy's own loss at the same
1344
+ nodes is the floor these numbers can resolve: about 0.03% of pot on the flop and turn,
1345
+ 0.06% at the root.
1346
+
1347
+ **The exact solver against postflop-solver.** Seven spots, solved exactly to 0.3% of pot
1348
+ on four threads at 32 bits. Our regrets on the actions either solver plays differ from
1349
+ the stored ones by 0.014–0.050% of pot on average, and by 0.16% at the worst
1350
+ well-reached node. Our root play loses what the stored strategy does at its own values.
1351
+ Larger differences are confined to actions neither solver plays, chiefly shoves, whose
1352
+ values neither solve trains closely:
1353
+
1354
+ | Spot | Board | Pot | Iterations, time | Played-action regret error, flop / turn (worst node) |
1355
+ |---|---|---|---|---|
1356
+ | f03 | 7c 6s Jc | 3-bet | 140, 61 s | 0.014 / 0.020% (0.064) |
1357
+ | f15 | As Kc 3d | 3-bet | 140, 92 s | 0.041 / 0.021% (0.153) |
1358
+ | f23 | 2d 3h 2c | 3-bet | 160, 79 s | 0.019 / 0.021% (0.062) |
1359
+ | f79 | 4s 7c 4c | 3-bet | 130, 59 s | 0.017 / 0.023% (0.096) |
1360
+ | f85 | 5s Js 6s | single-raised | 390, 249 s | 0.018 / 0.019% (0.055) |
1361
+ | f05 | 5s Ts Ac | single-raised | 410, 555 s | 0.021 / 0.050% (0.158) |
1362
+ | f01 | 7h 5c 7s | single-raised | 440, 698 s | 0.024 / 0.017% (0.059) |
1363
+
1364
+ **Each option.** Measured on three 3-bet pots (f03 two-tone, f15 rainbow, f79 paired), on
1365
+ four threads, at the iterations the exact solve took to 0.3% of pot. That makes each row
1366
+ the option's cost at equal iterations. Losses are in % of the node's pot, means over the
1367
+ spots. Root is OOP at the flop root / IP after a check.
1368
+
1369
+ | Option | Storage | Time | Root loss | Flop nodes | Turn nodes | True exploitability |
1370
+ |---|---|---|---|---|---|---|
1371
+ | exact | 1.00× | 1.00× | 0.059 / 0.054 | 0.030 | 0.031 | 0.27% |
1372
+ | `wasmStorage`, i16 | 0.52× | 1.16× | 0.059 / 0.067 | 0.033 | 0.035 | 0.37% |
1373
+ | `compactStorage` (with `wasmStorage`) | 0.37× | 1.37× | 0.063 / 0.080 | 0.045 | 0.039 | 0.63% |
1374
+ | `shareHistories` | 0.40× | 1.00× | 0.061 / 0.068 | 0.034 | 0.041 | 1.89% |
1375
+ | `shareHistories` + `compactStorage` | 0.15× | 1.40× | 0.067 / 0.083 | 0.041 | 0.047 | 2.08% |
1376
+ | `thinSizes` (15 of 61 nodes cut) | 0.74× | 0.66× | 0.067 / 0.294 | 0.084 | 0.048 | 0.22% in its own tree |
1377
+ | `thinSizes` + `shareHistories` | 0.35× | 0.72× | 0.071 / 0.288 | 0.084 | 0.049 | 2.07% in its own tree |
1378
+ | `chanceSampling` | 1.00× | 0.21× | 0.171 / 0.172 | 0.130 | 0.397 | 8.64% |
1379
+ | the same, 2× the iterations | 1.00× | 0.38× | 0.086 / 0.086 | 0.052 | 0.093 | 2.26% |
1380
+ | the same, 4× the iterations | 1.00× | 0.69× | 0.057 / 0.056 | 0.030 | 0.033 | 0.60% |
1381
+ | `shareHistories` + `chanceSampling` | 0.40× | 0.21× | 0.128 / 0.122 | 0.090 | 0.274 | 8.30% |
1382
+ | blueprint + `resolveSubgame` | 0.59× | 0.68× with the re-solves | 0.062 / 0.073 | 0.057 | 0.107; re-solved 0.053 | — |
1383
+ | `runoutBuckets: 3`, `coarseStart`, and their pairs | as without them | | | | | |
1384
+ | **`solveLite`'s blueprint (`litePreset`)**, to its `settle` stop (2.6× the iterations) | 0.22× | 0.30× | 0.052 / 0.068 | 0.052 | 0.127 | 1.89% |
1385
+ | **`largeTree`**, 4× the iterations | 0.38× | 0.58× | 0.057 / 0.289 | 0.082 | 0.048 | 0.39% in its own tree |
1386
+
1387
+ - **Storage options cost almost nothing at the root.** i16 stays within the noise. Compact
1388
+ storage and sharing add a few hundredths of a percent of pot. Sharing's exploitability
1389
+ plateau (1.9%) lies mostly in lines the stored nodes do not reach.
1390
+ - **`thinSizes`' cost is IP's bet after a check.** Away from the root it keeps one size. On
1391
+ these spots IP's 33% bet after a check is its main play, so the IP root loses 0.29%
1392
+ of pot. Its flop and turn means cover only the nodes its tree still holds. The 15 lines
1393
+ it cut are left out, so those means understate its cost.
1394
+ - **`chanceSampling` wins on time.** On four threads its iterations cost a fifth of exact
1395
+ ones. At equal iterations it is far from settled, but at four times the iterations, in
1396
+ 0.69× the exact solve's time, its root, flop and turn play match the exact solve's, though
1397
+ it is 0.60% of pot exploitable against 0.27%.
1398
+ - **`resolveSubgame`:** the blueprint here keeps the flop's betting and gives the turn and
1399
+ river one 75% bet, with no raise or shove there. Re-solving each stored turn with the
1400
+ full betting (200 iterations) halves the blueprint's turn loss, to 0.053% of pot
1401
+ against 0.031% exact.
1402
+ - **`runoutBuckets` folds nothing on any of the 70 spots, at any gap.** Their weighted
1403
+ ranges give no rank swap that maps both ranges onto themselves. So it, and
1404
+ `coarseStart`, which buckets the same way, leave these solves exactly as they were.
1405
+ - **The presets** (issue #115) cost what their parts do. Lite settles in 0.30× the exact solve's time
1406
+ in 0.22× its storage, with root play as close to the stored play as the exact solve's. Its turn
1407
+ nodes lose 0.127% of pot, because its turn keeps the 75% bet but drops the raise and the all-in the
1408
+ stored solves play, and it plateaus at sharing's 1.9% exploitability. `largeTree` costs `thinSizes`' IP root loss and
1409
+ nothing more, in 0.38× the storage and 0.58× the time.
1410
+
1411
+ `bench/reference/results/` has every number, per spot and per node. `test/combinations.test.ts` solves
1412
+ every pair of the eight opt-ins and the two presets on a small spot. Every pair runs, repeatable
1413
+ on two threads and matching one thread and the JavaScript engine. `test/presets-score.test.ts` scores both presets on f03 against the
1414
+ stored EVs, so a regression in any option they use fails `npm test` wherever the fixtures are
1415
+ checked out; elsewhere it skips.
1416
+
463
1417
  ## Verification
464
1418
 
465
1419
  - **A known answer.** The clairvoyance game — nuts and air against pure bluffcatchers on a
@@ -478,18 +1432,30 @@ enumerated and can be canonicalised for a 12× win.
478
1432
  runout count — invisible on a river board, where that factor is 1.
479
1433
  - Zero-sum to 1e-9, exploitability non-negative and non-increasing, and every strategy a
480
1434
  probability distribution.
1435
+ - **Against an independent solver.** On seven of napkinpoker's postflop-solver references,
1436
+ every texture, exact solves agree with the stored regrets to 0.01–0.05% of pot on the
1437
+ actions either plays (see [Every option on napkinpoker's reference solves](#every-option-on-napkinpokers-reference-solves)).
1438
+ - **Options in pairs.** Every pair of the eight opt-ins and the two presets is solved, repeated, compared across
1439
+ thread counts and engines, and checked to change nothing when one of them is off.
481
1440
 
482
1441
  ```bash
1442
+ npm run lint # conventions: kebab-case file names, tab indents, no focused tests
1443
+ npm run check # types, with unused locals, parameters and imports refused
483
1444
  npm test
484
1445
  ```
485
1446
 
486
1447
  ## Releasing
487
1448
 
488
1449
  `.github/workflows/publish.yml` publishes to npm from `main`. Every push to `main` is
489
- type-checked, tested and built; if the `version` in `package.json` is not on npm yet, it
1450
+ linted, type-checked, tested and built; if the `version` in `package.json` is not on npm yet, it
490
1451
  is published, with provenance. So a release is: bump `version`, merge to `main`. A push
491
1452
  that leaves the version alone publishes nothing.
492
1453
 
1454
+ A prerelease version (`0.5.0-beta.0`) is published under its own dist-tag, the word after the
1455
+ `-` (`beta`), so `npm install poker-flopsolve` keeps getting the latest stable release and the
1456
+ beta is installed by name: `npm install poker-flopsolve@beta`. A plain version is published as
1457
+ `latest`.
1458
+
493
1459
  It publishes by npm trusted publishing: npm trusts this repository's `publish.yml`
494
1460
  (set up under the package's settings on npmjs.com), the job proves who it is with GitHub's
495
1461
  OpenID Connect token, and no npm token is stored anywhere.