poker-flopsolve 0.5.0-beta.0 → 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/CHANGELOG.md +70 -0
- package/README.md +143 -27
- package/dist/browser-threads.js +36 -18
- package/dist/browser-threads.js.map +1 -1
- package/dist/browser.js +1566 -45
- package/dist/browser.js.map +1 -1
- package/dist/engine-worker.js +35 -17
- package/dist/engine-worker.js.map +1 -1
- package/dist/index.d.ts +203 -44
- package/dist/index.js +1566 -45
- package/dist/index.js.map +1 -1
- package/dist/worker.js +5 -2
- package/dist/worker.js.map +1 -1
- package/docs/APPROXIMATIONS.md +22 -0
- package/package.json +6 -3
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,72 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 0.5.0-beta.1
|
|
4
|
+
|
|
5
|
+
The second beta of 0.5.0 (`npm install poker-flopsolve@beta`): everything since 0.5.0-beta.0.
|
|
6
|
+
|
|
7
|
+
### Lite: compress the ranges first (issue #156)
|
|
8
|
+
|
|
9
|
+
- `solveLite` and `liteConfig` take `compressRanges` (off by default): before the blueprint is
|
|
10
|
+
solved, each range keeps the fewest of its combinations, re-weighted, whose equity
|
|
11
|
+
distributions on this flop's boards stay within a tolerance (default 0.01) of the full
|
|
12
|
+
range's. `compressRanges(spot)` does the same on its own.
|
|
13
|
+
- For wide ranges. A button open against a big-blind call (433–518 combinations a side) on 4
|
|
14
|
+
threads settled in 40.6 s against 87.6 on As Kh 7d, 31.2 against 62.1 on Ts 9s 4h and 16.5
|
|
15
|
+
against 27.3 on Ks 9s 4s, in 0.42–0.72× the storage, with the root play 1.2–2.7 points from
|
|
16
|
+
Lite's on the full ranges, where two Lite solves of the full ranges were 1.8–3.0 apart.
|
|
17
|
+
- On narrow ranges it gains little and can lose. The bench ranges, about 200 combinations a side:
|
|
18
|
+
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 combinations breaks the
|
|
19
|
+
symmetries that fold boards together.
|
|
20
|
+
- It keeps how the range plays, not what one combination does: the blueprint and its re-solves
|
|
21
|
+
hold a strategy only for the combinations kept.
|
|
22
|
+
- The compressor is poker-rangecompress, vendored as `src/vendor/range-compress.js` (JavaScript
|
|
23
|
+
with its WebAssembly kernels embedded; the package still has no dependencies). It adds about
|
|
24
|
+
60 kB to the bundle, before minifying.
|
|
25
|
+
|
|
26
|
+
### Lite's exploitability in the full game (issue #154)
|
|
27
|
+
|
|
28
|
+
- `exploitabilityInExact(lite, exact)` measures how exploitable a Lite solve's play is in
|
|
29
|
+
the caller's full game. It copies Lite's strategy onto a run of the full spot wherever
|
|
30
|
+
Lite has the decision, keeps that run's own play below the sizes and raises Lite cut, and
|
|
31
|
+
returns the exploitability as a % of the pot.
|
|
32
|
+
- The benchmark page's Accuracy box, after a Lite solve, offers "Measure against Exact"
|
|
33
|
+
when the full game fits in the memory left beside it. It solves Exact to the form's
|
|
34
|
+
target and shows Lite's exploitability with Exact's own beside it.
|
|
35
|
+
|
|
36
|
+
### Faster: engine threads share out boards (issue #133)
|
|
37
|
+
|
|
38
|
+
- On the WebAssembly engine, threads take the split round's boards off a shared queue,
|
|
39
|
+
costliest first, instead of fixed slices. `solveLite` on As Kh 7d settled about 15% sooner
|
|
40
|
+
on 2 and 4 threads in headless Chromium (57.9 → 49.3 s, 33.7 → 28.1 s), turn re-solves
|
|
41
|
+
12–19% sooner; the slowest thread now walks within 1% of the mean, from about 13%.
|
|
42
|
+
- A threaded solve on the WebAssembly engine is now bitwise the same at every thread count
|
|
43
|
+
from two up, not only at a fixed count. One thread still agrees with it only to floating
|
|
44
|
+
point, as before.
|
|
45
|
+
- `npm run bench:lite` (issue #133) times `solveLite` phase by phase in any browser, at each
|
|
46
|
+
thread count, and reports each thread's walking time.
|
|
47
|
+
|
|
48
|
+
### Changed: EV is a percentage of the pot (issue #130) — breaking
|
|
49
|
+
|
|
50
|
+
- `Solution.ev(player)` and `Solution.handEvs(player)` now report the player's **share of the
|
|
51
|
+
pot, in percent**, instead of chips against a half-pot baseline. Folding (or losing every
|
|
52
|
+
showdown) is 0%, winning the pot uncontested is 100%, and `ev(0) + ev(1)` is 100. On Ks 9d 4c
|
|
53
|
+
with a 60 pot, `12.5 / −12.5` chips now reads `70.8 / 29.2`%.
|
|
54
|
+
- The pot is the spot's starting pot (`SpotConfig.pot`), exposed as `Solution.evPot`. Convert
|
|
55
|
+
back with **old chips = `pct / 100 × pot − pot / 2`**, or read `Solution.evChips(player)`
|
|
56
|
+
and `Solution.handEvsChips(player)`, which return the old numbers.
|
|
57
|
+
- New `SpotConfig.evPot` (default `pot`). `Solution.subgameAt` sets it to the original spot's,
|
|
58
|
+
so `resolveSubgame` and `LiteSolution.resolve` (nested too) report in % of the **original
|
|
59
|
+
flop pot**: values read the same way down a hand, and folding at a subgame's root reads below
|
|
60
|
+
0 (the chips put in on earlier streets). For those, convert with the flop pot, `evPot`.
|
|
61
|
+
- Applies to the presets' solutions (`solveLite`, `largeTree`), subgame solutions, the CLI and
|
|
62
|
+
the UI readout, which now show `%`.
|
|
63
|
+
- Unchanged, still chips on the half-pot baseline: `Solver.valuesAt`, `pairValuesAt`,
|
|
64
|
+
`rootValues`, `handEvs` on the `Solver`, regrets, `ResolvedSubgame.alternative` / `entered`,
|
|
65
|
+
and `exploitability()` (`exploitabilityPercent()` stays % of the spot's own pot).
|
|
66
|
+
- napkinpoker: `tools/bench/flopsolve/flop-vs-pfrs.mjs` reads `ev()` and needs `evChips()` to
|
|
67
|
+
keep its chip numbers, or a `%` label; `src/villain/flopsolve-villain.js` reads `valuesAt`,
|
|
68
|
+
which is unchanged.
|
|
69
|
+
|
|
3
70
|
## 0.5.0-beta.0
|
|
4
71
|
|
|
5
72
|
The first beta of 0.5.0, published under npm's `beta` tag (`npm install poker-flopsolve@beta`); `latest` stays 0.4.1 until 0.5.0. A minor release. Every approximation below is opt-in and off by default. The README's
|
|
@@ -21,6 +88,9 @@ The first beta of 0.5.0, published under npm's `beta` tag (`npm install poker-fl
|
|
|
21
88
|
a storage budget, ranked on a short solve of the blueprint with its river checked down
|
|
22
89
|
(`checkedDown`, `keepWithin`); `LiteSolution.kept` lists them. On issue #47's flops, 150 MiB at 16
|
|
23
90
|
bits cut a turn re-solve's best-response gain by a third to a half, root play unchanged.
|
|
91
|
+
With a budget, `settle`'s tolerance defaults to 0.005, not 0.01 (#123): the kept lines' turn
|
|
92
|
+
ranges go on improving after the root play settles, and stopping later cut the re-solve gain by
|
|
93
|
+
15–28% more for out of position (3–34% in position) for 16–32% more time on 4 threads.
|
|
24
94
|
|
|
25
95
|
### New opt-ins since 0.4.1
|
|
26
96
|
|
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); //
|
|
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
|
```
|
|
@@ -166,10 +192,31 @@ dropped from both, which suits imported ranges full of hands at a percent or two
|
|
|
166
192
|
|
|
167
193
|
## Reading a solved spot
|
|
168
194
|
|
|
169
|
-
`solution.
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
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.
|
|
173
220
|
|
|
174
221
|
Both read the average strategy by default. With `approximations: { currentProfileEv: true }`
|
|
175
222
|
they read the current (regret-matched) profile instead: the strategy the next iteration would
|
|
@@ -250,7 +297,9 @@ const detailed = solve(turn, { targetPercent: 0.3 });
|
|
|
250
297
|
|
|
251
298
|
`solution.subgameAt(node, board, betting?)` returns the spot that starts at a node that
|
|
252
299
|
opens a betting round. It carries the board dealt there, the pot and stacks as they stand,
|
|
253
|
-
and each player's range as their reach there (`solution.reachAt`)
|
|
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
|
|
254
303
|
per-combination weights as well as notation. Measured on the bench flop: the coarse flop
|
|
255
304
|
took 27 s and 150 MB with 3 threads. Each turn, re-solved with three sizes, two raises and
|
|
256
305
|
a shove, took about 7 s and 15 MB. The same rich tree solved from the flop would need
|
|
@@ -417,7 +466,7 @@ Pick a goal below, not a dozen options.
|
|
|
417
466
|
|---|---|---|---|---|
|
|
418
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 |
|
|
419
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 |
|
|
420
|
-
| Better turn re-solves, in a tab | `solveLite` with `keepBudget: 150 * 2 ** 20`, `precision: 'i16'`, `wasmStorage` |
|
|
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 |
|
|
421
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 |
|
|
422
471
|
| Exact | `solve(spot, { targetPercent })` | 9.2 s, 708 MiB (0.2%, Chromium) | 10.3 s (Node) | 5.6 s (Node) |
|
|
423
472
|
|
|
@@ -427,7 +476,8 @@ How each row was measured, all on 4 threads:
|
|
|
427
476
|
memory includes a turn re-solve. Root loss is what OOP's root play / IP's play after a check give up
|
|
428
477
|
at the unshared blueprint's per-action values, % of pot. The phone row's 300 MiB is Node's peak on
|
|
429
478
|
rainbow. The re-solve row is issue #113's: the same blueprint at 16 bits, keeping the most-reached
|
|
430
|
-
flop lines that 150 MiB holds, the pick included in the time
|
|
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
|
|
431
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
|
|
432
482
|
unshared blueprint 0.4–0.7.
|
|
433
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
|
|
@@ -504,6 +554,7 @@ against the exact solve at equal iterations, root loss OOP / IP in % of pot (the
|
|
|
504
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)) |
|
|
505
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)) |
|
|
506
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)) |
|
|
507
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)) |
|
|
508
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)) |
|
|
509
560
|
| `approximations.chanceSampling` | preset-internal (both) | both, threaded | — | at 4× the iterations: 0.69× time, root 0.057 / 0.056, 0.60% exploitable |
|
|
@@ -685,10 +736,20 @@ the difference.
|
|
|
685
736
|
|
|
686
737
|
`solve(spot, { workers })` splits the runouts across threads, the calling thread included:
|
|
687
738
|
`workers: 2` is the caller and one worker thread. Storage is indexed runout-outermost, so
|
|
688
|
-
each
|
|
739
|
+
each runout's storage is walked by one thread at a time and no thread takes a lock. Only the round above
|
|
689
740
|
the split stays on the main thread alone, because CFR+ clamps regrets at zero and partial
|
|
690
741
|
sums cannot be added through a clamp. Exploitability and EV passes are split the same way.
|
|
691
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
|
+
|
|
692
753
|
Measured on a 133 vs 145 combo spot, 8 cores:
|
|
693
754
|
|
|
694
755
|
| Workers | Turn, 400 iters | Flop, 100 iters |
|
|
@@ -709,9 +770,12 @@ any chance to report it (a Node worker out of heap, a worker the browser kills)
|
|
|
709
770
|
a backstop instead: the main thread waits for the others at most 20× its own share of the
|
|
710
771
|
step, and never less than a minute, before it gives up on them.
|
|
711
772
|
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
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
|
|
715
779
|
that rounding, as it does any small change: an action's share follows its regret's sign,
|
|
716
780
|
and where hands are close to indifferent the 32-bit gap grows from iteration to iteration.
|
|
717
781
|
Measured on a small turn (`Ah Kd Qc 8s`, half- and full-pot bets, two raises), 1 and 2
|
|
@@ -765,7 +829,7 @@ const turn = lite.resolve(node, board, { player: 0, iterations: 300 });
|
|
|
765
829
|
`lite.changes` says what the blueprint cut from your betting and what it switched on (see
|
|
766
830
|
[The presets](#the-presets)). `litePreset(spot)` returns the blueprint spot, the solve settings and
|
|
767
831
|
that report without solving, for a page that steps its own run; `liteConfig(spot)` returns the spot
|
|
768
|
-
alone. `trackSettle()` gives the same stop for such a loop. Lite is a shared blueprint, so it
|
|
832
|
+
alone. `trackSettle(preset.options.settle)` gives the same stop for such a loop. Lite is a shared blueprint, so it
|
|
769
833
|
never reaches an exploitability target: it plateaus a few percent of the pot from
|
|
770
834
|
equilibrium while its first decisions go on settling (issue #85). `SolveOptions.settle`
|
|
771
835
|
is the stop. Every 20 iterations it reads the average strategy at the root and at in
|
|
@@ -773,6 +837,47 @@ position's decision after a check. It stops once both have moved less than 1% of
|
|
|
773
837
|
range, by total variation weighted by range, twice in a row. That is two strategy reads,
|
|
774
838
|
with no best-response pass. It works on any solve: `solve(spot, { settle: {} })`.
|
|
775
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
|
+
|
|
776
881
|
Measured on that spot's betting, in headless Chromium. The time counts solving and the settle
|
|
777
882
|
checks. Root play loss is what OOP's root mix and IP's mix after a check lose at the
|
|
778
883
|
unshared blueprint's per-action values (solved to 0.05% of pot), with that blueprint's
|
|
@@ -814,19 +919,23 @@ const lite = solveLite(spot, { workers: 4, keepBudget: 150 * 2 ** 20, precision:
|
|
|
814
919
|
lite.kept; // ['check check /', 'bet 18.15 call /', 'bet 82.5 call /'] on As Kh 7d
|
|
815
920
|
```
|
|
816
921
|
|
|
817
|
-
|
|
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:
|
|
818
925
|
|
|
819
|
-
| flop | kept | settled,
|
|
820
|
-
|
|
821
|
-
| As Kh 7d | 3 lines |
|
|
822
|
-
| Ts 9s 4h | 6 lines |
|
|
823
|
-
| Ks 9s 4s | all 19 |
|
|
824
|
-
|
|
825
|
-
The root play is unchanged, and the re-solve gain
|
|
826
|
-
|
|
827
|
-
|
|
828
|
-
|
|
829
|
-
1.
|
|
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.
|
|
830
939
|
`bench/lite/` has the scripts and logs.
|
|
831
940
|
|
|
832
941
|
### Fitting a large tree (`largeTree`)
|
|
@@ -1019,7 +1128,10 @@ the WebAssembly engine in Node and the browser, the JavaScript engine in Node).
|
|
|
1019
1128
|
samples the deals of its own runouts, and whether a deal is walked on an iteration is a hash
|
|
1020
1129
|
of its chance node, the deal and the iteration, so every thread count walks the same deals
|
|
1021
1130
|
and a fixed count is bitwise repeatable. On 4 Chromium threads it ran 3.1–3.2× faster than on
|
|
1022
|
-
one (`bench/blueprint-share/README.md`). The baselines count against `maxBytes
|
|
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
|
|
1023
1135
|
river deals only. It works over any storage: 32 or 16 bits (since issue #102) or compact.
|
|
1024
1136
|
|
|
1025
1137
|
### Storage: 16-bit and compact
|
|
@@ -1198,7 +1310,11 @@ realistic spots it folds nothing, at any gap (see
|
|
|
1198
1310
|
spot, with runouts bucketed as by `runoutBuckets: 3`, for that many iterations. It then
|
|
1199
1311
|
starts the real spot from those regrets. Coarse iterations are cheaper, and the real solve
|
|
1200
1312
|
picks up roughly where they left off. The answer is still the real spot's, and
|
|
1201
|
-
exploitability measures the real game. Off by default.
|
|
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.
|
|
1202
1318
|
|
|
1203
1319
|
Measured in Chromium on one thread, stopped at 15 s, 40 coarse iterations, with root-EV
|
|
1204
1320
|
error per combination (range-weighted mean, % of pot) against a 0.1% reference:
|
package/dist/browser-threads.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// src/engine.ts
|
|
2
2
|
var wasm = globalThis.WebAssembly;
|
|
3
|
-
var ENGINE_CONTROL = { generation: 0, done: 1, command: 2, mode: 3, traverser: 4, ready: 5, failed: 6, size: 8 };
|
|
3
|
+
var ENGINE_CONTROL = { generation: 0, done: 1, command: 2, mode: 3, traverser: 4, ready: 5, failed: 6, next: 7, size: 8 };
|
|
4
4
|
|
|
5
5
|
// src/engine-thread.ts
|
|
6
6
|
function serveEngine(setup) {
|
|
@@ -11,6 +11,7 @@ function serveEngine(setup) {
|
|
|
11
11
|
const TRAVERSER = 4;
|
|
12
12
|
const READY = 5;
|
|
13
13
|
const FAILED = 6;
|
|
14
|
+
const NEXT = 7;
|
|
14
15
|
const EXIT = 1;
|
|
15
16
|
const api = globalThis.WebAssembly;
|
|
16
17
|
const memory = setup.memory;
|
|
@@ -26,7 +27,8 @@ function serveEngine(setup) {
|
|
|
26
27
|
engine.init(setup.header);
|
|
27
28
|
engine.setMaxActions(setup.maxActions);
|
|
28
29
|
engine.setExchange(setup.exchange[0], setup.exchange[1], setup.exchange[2], setup.exchange[3]);
|
|
29
|
-
|
|
30
|
+
const [round, boards] = setup.shard;
|
|
31
|
+
engine.setShard(round, 0, 0);
|
|
30
32
|
engine.setPhase(0, 1);
|
|
31
33
|
const shared = setup.shared;
|
|
32
34
|
if (shared) engine.setShared(shared[0], shared[1], shared[2]);
|
|
@@ -37,8 +39,13 @@ function serveEngine(setup) {
|
|
|
37
39
|
const settings = new Float64Array(setup.settings);
|
|
38
40
|
const entries = setup.entryNodes.length;
|
|
39
41
|
const rowBytes = setup.stride * 4;
|
|
40
|
-
const
|
|
42
|
+
const stride = setup.stride;
|
|
41
43
|
const reach = setup.exchange[1];
|
|
44
|
+
const order = new Int32Array(setup.schedule, 0, boards);
|
|
45
|
+
const cost = new Float64Array(setup.schedule, Math.ceil(boards / 2) * 8, 2 * boards);
|
|
46
|
+
const into = setup.boardValues >>> 2;
|
|
47
|
+
const profile = new Float64Array(setup.profile[0]);
|
|
48
|
+
const busy = setup.profile[1];
|
|
42
49
|
let generation = Atomics.load(control, GENERATION);
|
|
43
50
|
Atomics.add(control, READY, 1);
|
|
44
51
|
Atomics.notify(control, READY);
|
|
@@ -57,22 +64,33 @@ function serveEngine(setup) {
|
|
|
57
64
|
try {
|
|
58
65
|
engine.setPhase(0, settings[5]);
|
|
59
66
|
if (needsIteration) engine.setIteration(settings[6], settings[7]);
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
67
|
+
const heap = new Float32Array(memory.buffer);
|
|
68
|
+
const started = performance.now();
|
|
69
|
+
for (; ; ) {
|
|
70
|
+
const taken = Atomics.add(control, NEXT, 1);
|
|
71
|
+
if (taken >= boards) break;
|
|
72
|
+
const board = order[taken];
|
|
73
|
+
engine.setShard(round, board, board + 1);
|
|
74
|
+
const boardStarted = performance.now();
|
|
75
|
+
for (let entry = 0; entry < entries; entry++) {
|
|
76
|
+
const slot = reach + entry * 2 * rowBytes;
|
|
77
|
+
const out = engine.runChance(
|
|
78
|
+
mode,
|
|
79
|
+
traverser,
|
|
80
|
+
setup.entryNodes[entry],
|
|
81
|
+
slot,
|
|
82
|
+
slot + rowBytes,
|
|
83
|
+
positive,
|
|
84
|
+
negative,
|
|
85
|
+
sum,
|
|
86
|
+
weight,
|
|
87
|
+
clamp
|
|
88
|
+
) >>> 2;
|
|
89
|
+
heap.copyWithin(into + (board * entries + entry) * stride, out, out + stride);
|
|
90
|
+
}
|
|
91
|
+
if (mode === 0 && settings[5] === 1) cost[traverser * boards + board] = performance.now() - boardStarted;
|
|
75
92
|
}
|
|
93
|
+
profile[busy] += performance.now() - started;
|
|
76
94
|
} catch (error) {
|
|
77
95
|
Atomics.store(control, FAILED, 1);
|
|
78
96
|
throw error;
|