- preflop_plo4: echter Fehler.015baff(PLO5-Kalibrierung) aenderte die geteilten Gewichte, die plo4_score mitbenutzt; die PLO4-Perzentiltabelle war veraltet (233 statt 231 Stufen). Neu erzeugt (print_table). - cfr_multi / generated_charts_reproduce "frozen file": Kommentartabellen im Repo hatten zusammengezogene Leerzeichen; Renderer-Ausgabe zurueckgeschrieben (git diff -w leer, Zahlen unveraendert). - generated_charts_plausibility x3: verglichen gegen handkopierte Werte bzw. Nash ohne Antes, die Tabellen rechnen seit3d65e85mit Rake+Antes. Jetzt: Ein-Verteidiger-Bezug = BASELINE derselben Umgebung; HU-Nash gegen dasselbe Spiel ohne Rake/Antes geloest, ausgelieferte Tabelle mindestens so breit; Positions-Teilmengen: eine indifferente Mischung (98s BTN 40bb 30 %) erlaubt. - preflop_multi_advice x3: die festen Grenzhaende (Q8o, KTo, 77) liegen nach dem Neurechnen innen; Grenzhaende werden ueber alle 169 Klassen gesucht. - pipeline_bluff: "Steal weiter gegen Nits" ist abgeschaltet, nicht kaputt: read_gate verwirft Nit-Reads (earned_trust 0, gemessen -50 bb/100). Test prueft jetzt: gegen Nits blind, gegen Stations enger. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
175 lines
7.7 KiB
Rust
175 lines
7.7 KiB
Rust
//! End-to-end spec for bluffing and bluff catching, steered by opponent frequencies.
|
||
|
||
mod support;
|
||
|
||
use rechner::wire::respond::respond;
|
||
use support::{action, board_json, cards_json, field, short};
|
||
|
||
const NIT: &str = r#","profile":{"vpip":0.11,"pfr":0.08,"foldToBet":0.8,"aggression":0.15}"#;
|
||
const STATION: &str = r#","profile":{"vpip":0.55,"pfr":0.05,"foldToBet":0.15,"aggression":0.2}"#;
|
||
const MANIAC: &str = r#","profile":{"vpip":0.55,"pfr":0.35,"foldToBet":0.35,"aggression":0.8}"#;
|
||
const NEVER_FOLDS: &str = r#","profile":{"foldToBet":0.05}"#;
|
||
|
||
fn reason(out: &str) -> String {
|
||
field(out, "reason").unwrap_or("").to_string()
|
||
}
|
||
|
||
/// Heads-up river, checked to hero (button, seat 6) by the villain in seat 1.
|
||
fn river_checked_to_hero(hero: &str, board: &str, profile: &str) -> String {
|
||
format!(
|
||
r#"{{"variant":"NLHE","bigBlind":1,"seats":6,"heroSeat":6,"buttonSeat":6,"heroCards":{},"board":{},"street":"RIVER","pot":20,"toCall":0,"heroStack":100,"minRaiseTo":1,"maxRaiseTo":100,"legalActions":["CHECK","RAISE"],"villains":[{{"seat":1,"stack":100,"folded":false{profile}}}]}}"#,
|
||
cards_json(&short(hero)),
|
||
board_json(&short(board)),
|
||
)
|
||
}
|
||
|
||
/// Hero (button) raised preflop, the small blind called, checked down to the river,
|
||
/// where the small blind bets the pot (6 into 6).
|
||
fn river_facing_a_pot_bet(hero: &str, board: &str, profile: &str) -> String {
|
||
let history = r#"[{"street":"PREFLOP","seat":1,"action":"POST_SB","amount":0.5},{"street":"PREFLOP","seat":2,"action":"POST_BB","amount":1},{"street":"PREFLOP","seat":6,"action":"RAISE","amount":2.5},{"street":"PREFLOP","seat":1,"action":"CALL","amount":2.5},{"street":"PREFLOP","seat":2,"action":"FOLD"},{"street":"FLOP","seat":1,"action":"CHECK"},{"street":"FLOP","seat":6,"action":"CHECK"},{"street":"TURN","seat":1,"action":"CHECK"},{"street":"TURN","seat":6,"action":"CHECK"},{"street":"RIVER","seat":1,"action":"BET","amount":6}]"#;
|
||
format!(
|
||
r#"{{"variant":"NLHE","bigBlind":1,"seats":6,"heroSeat":6,"buttonSeat":6,"heroCards":{},"board":{},"street":"RIVER","pot":12,"toCall":6,"heroStack":97.5,"minRaiseTo":12,"maxRaiseTo":97.5,"legalActions":["FOLD","CALL","RAISE"],"villains":[{{"seat":1,"stack":91.5,"folded":false{profile}}},{{"seat":2,"stack":99,"folded":true}}],"history":{history}}}"#,
|
||
cards_json(&short(hero)),
|
||
board_json(&short(board)),
|
||
)
|
||
}
|
||
|
||
/// Unopened pot, hero on the button, both blinds with the same profile.
|
||
fn steal(hero: &str, profile: &str) -> String {
|
||
format!(
|
||
r#"{{"variant":"NLHE","bigBlind":1,"seats":6,"heroSeat":6,"buttonSeat":6,"heroCards":{},"street":"PREFLOP","pot":1.5,"toCall":1,"heroStack":100,"minRaiseTo":2,"maxRaiseTo":100,"legalActions":["FOLD","CALL","RAISE"],"villains":[{{"seat":1,"stack":100,"folded":false{profile}}},{{"seat":2,"stack":100,"folded":false{profile}}}]}}"#,
|
||
cards_json(&short(hero)),
|
||
)
|
||
}
|
||
|
||
/// Air on the river: no pair, no made straight or flush.
|
||
const AIR: [(&str, &str); 6] = [
|
||
("6h 5h", "As Kd 9c 7s 2d"),
|
||
("Qc Jc", "As 8d 5h 3s 2c"),
|
||
("Th 9h", "Ac Kd 6s 4c 2d"),
|
||
("7d 6d", "Kc Qs Jh 3c 2s"),
|
||
("Jd Td", "As 8c 6h 4d 3s"),
|
||
("8s 7s", "Ad Qc Th 4h 2c"),
|
||
];
|
||
|
||
fn bluffs(profile: &str) -> usize {
|
||
AIR.iter()
|
||
.filter(|(hero, board)| action(&respond(&river_checked_to_hero(hero, board, profile))) == "RAISE")
|
||
.count()
|
||
}
|
||
|
||
// ---------- Bluffing ----------
|
||
|
||
#[test]
|
||
fn the_nit_gets_bluffed_with_air() {
|
||
let out = respond(&river_checked_to_hero("6h 5h", "As Kd 9c 7s 2d", NIT));
|
||
assert_eq!(action(&out), "RAISE", "{out}");
|
||
assert!(reason(&out).contains("bluff"), "{out}");
|
||
}
|
||
|
||
#[test]
|
||
fn the_calling_station_does_not() {
|
||
let out = respond(&river_checked_to_hero("6h 5h", "As Kd 9c 7s 2d", STATION));
|
||
assert_eq!(action(&out), "CHECK", "{out}");
|
||
}
|
||
|
||
#[test]
|
||
fn fewer_bluffs_against_the_station_more_against_the_nit() {
|
||
let (nit, unknown, station) = (bluffs(NIT), bluffs(""), bluffs(STATION));
|
||
assert!(nit > unknown || nit == AIR.len(), "nit {nit}, unknown {unknown}");
|
||
assert!(unknown >= station, "unknown {unknown}, station {station}");
|
||
assert_eq!(station, 0);
|
||
assert_eq!(nit, AIR.len());
|
||
}
|
||
|
||
#[test]
|
||
fn never_bluff_someone_who_never_folds() {
|
||
assert_eq!(bluffs(NEVER_FOLDS), 0);
|
||
}
|
||
|
||
// ---------- Stealing ----------
|
||
|
||
/// One hand of each of the 169 classes.
|
||
fn every_class() -> Vec<String> {
|
||
let ranks = ['A', 'K', 'Q', 'J', 'T', '9', '8', '7', '6', '5', '4', '3', '2'];
|
||
let mut hands = Vec::new();
|
||
for (i, hi) in ranks.iter().enumerate() {
|
||
hands.push(format!("{hi}d {hi}c"));
|
||
for lo in &ranks[i + 1..] {
|
||
hands.push(format!("{hi}d {lo}d"));
|
||
hands.push(format!("{hi}d {lo}c"));
|
||
}
|
||
}
|
||
hands
|
||
}
|
||
|
||
#[test]
|
||
fn steal_narrower_against_stations_and_blind_against_nits() {
|
||
// The button opens the CFR range against both blinds; against two calling stations the steal
|
||
// shrinks. The test used to claim the steal also WIDENS against two nits (Kd4c folded blind,
|
||
// stolen from nits). That read no longer reaches the decision: the read gate drops every nit
|
||
// read (`engine::read_gate::earned_trust(Nit) = 0.0`, measured heads-up −50 bb/100 against
|
||
// blind play), so against nits the button plays the equilibrium hand for hand. The pinned
|
||
// border hands (Kd4c, Kd7c) also moved inside the range with the rake/ante re-solve (3d65e85);
|
||
// the hands are now searched over all 169 classes.
|
||
let folded = |a: &str| ["FOLD", "ABSTAIN"].contains(&a);
|
||
let mut shrunk = 0;
|
||
for hero in every_class() {
|
||
let base = action(&respond(&steal(&hero, "")));
|
||
let nit = action(&respond(&steal(&hero, NIT)));
|
||
let station = respond(&steal(&hero, STATION));
|
||
assert_eq!(nit, base, "{hero}: the nit read is gated, the steal stays blind");
|
||
if base == "RAISE" && folded(&action(&station)) {
|
||
assert!(reason(&station).contains("exploit"), "{hero}: {station}");
|
||
shrunk += 1;
|
||
}
|
||
// Never the other way: a hand folded blind is not stolen from stations.
|
||
if folded(&base) {
|
||
assert!(folded(&action(&station)), "{hero}: folded blind, stolen from stations");
|
||
}
|
||
}
|
||
assert!(shrunk > 0, "no equilibrium open is dropped against stations");
|
||
}
|
||
|
||
// ---------- Bluff catching ----------
|
||
|
||
#[test]
|
||
fn a_bluff_catcher_calls_the_maniac() {
|
||
let out = respond(&river_facing_a_pot_bet("Qh 9h", "Ks 9d 4c 2s 7h", MANIAC));
|
||
assert_eq!(action(&out), "CALL", "{out}");
|
||
}
|
||
|
||
#[test]
|
||
fn the_same_bluff_catcher_folds_to_the_nit() {
|
||
let out = respond(&river_facing_a_pot_bet("Qh 9h", "Ks 9d 4c 2s 7h", NIT));
|
||
assert!(["FOLD", "ABSTAIN"].contains(&action(&out).as_str()), "{out}");
|
||
}
|
||
|
||
#[test]
|
||
fn no_bluff_catch_against_a_range_without_bluffs() {
|
||
let honest = r#","profile":{"vpip":0.25,"pfr":0.18,"foldToBet":0.5,"aggression":0.0}"#;
|
||
let out = respond(&river_facing_a_pot_bet("Qh 9h", "Ks 9d 4c 2s 7h", honest));
|
||
assert!(["FOLD", "ABSTAIN"].contains(&action(&out).as_str()), "{out}");
|
||
}
|
||
|
||
#[test]
|
||
fn a_value_hand_still_calls_or_raises_the_nit() {
|
||
let out = respond(&river_facing_a_pot_bet("Kh Kc", "Ks 9d 4c 2s 7h", NIT));
|
||
assert!(["CALL", "RAISE"].contains(&action(&out).as_str()), "{out}");
|
||
}
|
||
|
||
// ---------- Semibluffs first ----------
|
||
|
||
#[test]
|
||
fn draws_raise_as_semibluffs_not_as_pure_bluffs() {
|
||
let line = format!(
|
||
r#"{{"variant":"NLHE","bigBlind":1,"seats":6,"heroSeat":6,"buttonSeat":6,"heroCards":{},"board":{},"street":"FLOP","pot":10,"toCall":0,"heroStack":100,"minRaiseTo":1,"maxRaiseTo":100,"legalActions":["CHECK","RAISE"],"villains":[{{"seat":1,"stack":100,"folded":false{NIT}}}]}}"#,
|
||
cards_json(&short("8h 7h")),
|
||
board_json(&short("Kh 4h 2c")),
|
||
);
|
||
let out = respond(&line);
|
||
assert_eq!(action(&out), "RAISE", "{out}");
|
||
assert!(reason(&out).contains("semibluff"), "{out}");
|
||
}
|
||
|