You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Fix 1-deck surrender strategy using composition-weighted EVs
- Add composition-weighted EV calculation for 1-2 deck stiff hands (12+)
- Add MC-verified exception for 1-deck H17 hard 17 vs A (standing beats surrender)
- Add validation to run_mc_batch.py to catch sur > nosur violations
- Re-run MC for all 1-deck configs with corrected strategies
- Consolidate docs: add monte-carlo.md, update algorithm.md, remove duplicate
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Copy file name to clipboardExpand all lines: docs/algorithm.md
+53Lines changed: 53 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -165,3 +165,56 @@ For infinite deck (num_decks = 0), standard probabilities are used:
165
165
| 2-9 | 1/13 each |
166
166
| 10,J,Q,K | 4/13 combined |
167
167
| A | 1/13 |
168
+
169
+
## Small Deck Composition Weighting
170
+
171
+
For 1-2 deck games, the optimal action can differ based on the specific cards in hand. For example, hard 15 can be:
172
+
- (10, 5) - 64 ways
173
+
- (9, 6) - 16 ways
174
+
- (8, 7) - 16 ways
175
+
176
+
Each composition has different EVs due to composition-dependent effects. For large decks, these differences are negligible. For small decks, they can change the optimal action.
177
+
178
+
### Weighted Average Approach
179
+
180
+
For stiff hands (12+) in 1-2 deck games, we calculate weighted average EV across all 2-card compositions:
181
+
182
+
```python
183
+
for (c1, c2) in compositions:
184
+
ways = count_ways(c1, c2) # probability weight
185
+
evs = get_all_evs((c1, c2), dealer_upcard)
186
+
for action, ev in evs.items():
187
+
weighted_evs[action] += ways * ev
188
+
189
+
avg_evs = {action: total / total_ways for action, total in weighted_evs.items()}
190
+
```
191
+
192
+
This ensures the strategy recommendation works well across all hand compositions, not just the (10, X) composition traditionally used.
193
+
194
+
## MC-Verified Exceptions
195
+
196
+
Monte Carlo simulation with realistic shoe dynamics sometimes reveals that the EV calculator's recommendation is suboptimal. These cases are rare and occur in small deck games where shoe composition effects are significant.
197
+
198
+
### 1-Deck H17: Hard 17 vs A
199
+
200
+
The EV calculator recommends surrender for hard 17 vs A in 1-deck H17 games (margin: +0.0097). However, MC simulation with 5+ billion hands shows that standing is actually better:
201
+
202
+
| Strategy | House Edge |
203
+
|----------|-----------|
204
+
| With 17 vs A surrender | 0.2895% |
205
+
| Without 17 vs A surrender | 0.2589% |
206
+
207
+
The difference (0.031%) is statistically significant. This exception is hardcoded in `evaluator.py`:
208
+
209
+
```python
210
+
# MC-verified exception: For 1-deck H17, standing on 17 vs A is better
211
+
# than surrender despite EV calculator showing otherwise.
212
+
if (num_decks ==1and dealer_hits_soft_17 and hand_total ==17
213
+
and dealer_upcard ==11and"surrender"in result):
214
+
del result["surrender"]
215
+
```
216
+
217
+
This issue does not affect:
218
+
- 1-deck S17 (standing is already optimal)
219
+
- 2+ deck games (composition effects are smaller)
220
+
- Other surrender hands (MC confirms they are correct)
| Deck model | Fresh minus known | Realistic shoe |
24
+
| Use case | Strategy generation | Verification |
25
+
26
+
## When Results Differ
27
+
28
+
For most configurations, EV and MC agree within 0.01%. Discrepancies indicate the EV model's assumptions break down.
29
+
30
+
### Small Deck Effects
31
+
32
+
1-2 deck games have significant composition effects:
33
+
- Removing 3 cards from 52 = 6% of deck
34
+
- Shoe state correlates with hand probabilities
35
+
- EV model's "fresh deck" assumption is less accurate
36
+
37
+
### Example: 1-Deck H17 Hard 17 vs A
38
+
39
+
EV calculator recommends surrender (margin: +0.0097). MC with 5B hands shows standing is better:
40
+
41
+
| Strategy | House Edge |
42
+
|----------|-----------|
43
+
| Surrender 17 vs A | 0.289% |
44
+
| Stand 17 vs A | 0.259% |
45
+
46
+
The EV model can't capture that when you're dealt (10,7) vs A, the shoe composition has changed in ways that make standing better than the model predicts.
47
+
48
+
## Verification Process
49
+
50
+
When adding new features (like surrender), verify with MC:
51
+
52
+
```bash
53
+
# Compare sur vs nosur for same config
54
+
./monte_carlo strategy-sur.json 10
55
+
./monte_carlo strategy-nosur.json 10
56
+
```
57
+
58
+
Expected: sur house edge < nosur (surrender helps player)
59
+
60
+
If sur > nosur, the surrender recommendations need adjustment.
61
+
62
+
## CUDA Implementation
63
+
64
+
See `cuda/README.md` for build and usage instructions.
0 commit comments