Gen 2 — Rollout-Based EHS (State of the Art)

# Gen 2 — Rollout-Based EHS

> **Current state, 2026-06-30.** Monte Carlo equity computation. The foundation for all modern postflop play.

## Role in the Framework

Gen 2 is the first generation to compute **actual hand equity** via Monte Carlo simulation. Instead of static rules, it evaluates `hs` (hand strength), `ppot` (positive potential), and `npot` (negative potential) to make decisions.

Gen 2 strategies are used:
- As **postflop baselines** (V4 was the previous production postflop)
- As **KEHU Nash HU equilibrium** (preflop only, 15-25BB)
- As the **foundation** that Gen 3 and Gen 4 build upon (shared `rollout_postflop_base.rs`)

## Preflop Maneuver

| Priority | Strategy | When |
|---|---|---|
| 1 | `g2_ke_hu_nash` | HU, 15-25 BB → Nash equilibrium push/fold/call |
| 2 | `g1_short_stack_preflop` | ≤25 BB → push/fold chart |
| 3 | `ng_preflop` | >25 BB → 169-hand ranking tables |

### NG Preflop (`ng_preflop`)
Ported from Java `PreFlopStrategyV1`. Uses three 169-hand ranking tables:
- **General table**: blended by active player count
- **HU table**: heads-up specific rankings
- **Profitability table**: expected BB/100 for each hand

### KEHU Nash HU (`g2_ke_hu_nash`)
Ported from Java `KEHU20BBNeqV3`. 19 embedded Nash equilibrium tables for HU play at 15BB and 20BB stack depths. Tournament-verified: **+2.97 to +4.46 BB/hand** in HU matchups.

## Postflop Maneuver

### Shared Base: `rollout_postflop_base.rs`
All Gen 2-4 postflop strategies inherit from this base (27 methods). Provides:
- Equity computation via Monte Carlo (`compute_equity`)
- Threshold-based decision logic (`should_call`, `should_raise`, `should_bet`)
- Bet sizing fractions (flop/turn/river, value/protection/bluff)
- Draw evaluation (flush draws, straight draws, nut draws)

### Gen 2 Postflop: `g2_postflop_rollout`
Computes equity vs **random opponent hands**. No range modeling.

- **Calls**: use `win_prob` (EHS — accounts for future cards)
- **Bets/Raises**: use `hs` (asserts current strength)
- Thresholds from `PostflopThresholds` (80+ configurable parameters)

### Gen 2 V4: `g2_postflop_rollout_v4`
Previous production (preserved). Adds **nut awareness**:
- `nutpot`: probability of improving to the nuts
- `EHS_nut_aware`: equity weighted by nut potential
- Better multi-way handling

## Key Equity Metrics (from `PotentialResult`)

| Metric | Meaning | Used For |
|---|---|---|
| `hs` | Hand strength (P(we have best hand now)) | Bets, raises |
| `win_prob` | EHS (hs adjusted for future cards) | Calls |
| `ppot` | Positive potential (P(improve to best)) | Draw calling |
| `npot` | Negative potential (P(lose current best)) | Conservative adjustments |
| `nutpot` | Probability of improving to nuts | Nut-aware equity (V4) |
| `rpot` | Robustness (equity stability across runouts) | Multiway adjustments |

## Monte Carlo Engine

- **Algorithm**: random opponent hand assignment + board completion + hand evaluation
- **Sample counts**: configurable (default 10,000; live config uses 50,000)
- **Parallelism**: Rayon-based, uses all available threads
- **Hand evaluation**: 2+2 lookup table (fastest known method)

## Configs

| Config | Chain |
|---|---|
| `cash_nl_gen2.toml` | ke_hu_nash → short_stack → ng_preflop → g2_postflop_rollout |
| `cash_nl_gen2_loose.toml` | same, value_bet_floor=0.55, wider calls |
| `cash_nl_gen2_tight.toml` | same, value_bet_floor=0.70, tighter calls, more bluffs |

## Key Files

| File | Content |
|---|---|
| `holdem_bots/src/cash/rollout_postflop_base.rs` | Shared base (27 methods) |
| `holdem_bots/src/cash/rollout_postflop_v2.rs` | Gen 2 original postflop |
| `holdem_bots/src/cash/rollout_postflop_v3.rs` | Gen 2 V4 nut-aware postflop |
| `holdem_bots/src/cash/ng_preflop.rs` | NG preflop (169-hand tables) |
| `holdem_bots/src/common/hand_rankings.rs` | 169-hand ranking tables |
| `holdem_bots/src/common/hand_potential.rs` | PotentialResult + MC engine |
| `holdem_bots/src/sng/ke_hu_nash.rs` | KEHU Nash HU strategy |
| `holdem_bots/src/sng/ke_hu_tables.rs` | 19 embedded Nash tables (3,272 lines) |

## Open Issues

- **Random opponent assumption**: Gen 2 computes equity vs random hands, ignoring that opponents who bet/call have stronger ranges. **Addressed by Gen 3** (range-aware equity).
- **No opponent adaptation**: Same thresholds regardless of opponent type. **Addressed by Gen 4** (adaptive observer).

## Where This Goes Next

Gen 2 is stable. It serves as the foundation and baseline for Gen 3-5. No active development beyond maintenance.

id: 8f9a294ec08d4a65ba90f901c64b1f81
parent_id: 1246bbc3bb4948fc8329079b84b4ae3d
created_time: 2026-06-28T05:15:52.185Z
updated_time: 2026-06-30T05:33:20.776Z
is_conflict: 0
latitude: 0.00000000
longitude: 0.00000000
altitude: 0.0000
author: 
source_url: 
is_todo: 0
todo_due: 0
todo_completed: 0
source: joplin-desktop
source_application: net.cozic.joplin-desktop
application_data: 
order: 1782623752185
user_created_time: 2026-06-28T05:15:52.185Z
user_updated_time: 2026-06-30T05:33:20.776Z
encryption_cipher_text: 
encryption_applied: 0
markup_language: 1
is_shared: 0
share_id: 
conflict_original_id: 
master_key_id: 
user_data: 
deleted_time: 0
type_: 1