Solver-Kern Stufe 4b: Auflagen Multiway (frische Scheibe +0,76 bb/100, Top-Paar-Flop-Fold-Sperre, Drilling/Monster Flop/Turn ausgeschlossen)

SOLVER3_FOHNE, SOLVER3_TOHNE, SOLVER3_FSPERRE (aus, live bitgleich); drei.py DREI_FENSTER; drei_kipp.py Mischarme.
Pflicht 39/44, Latenz max 1215 ms, Faustregel 97->78. Bericht messung/solver_kern/STUFE4B.md.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-11-19 17:11:34 +01:00
co-authored by Claude Opus 5.5
parent 2491ecbfb2
commit c3e2726cd0
21 changed files with 799 additions and 7 deletions
+49 -2
View File
@@ -34,6 +34,13 @@ static OHNE: AtomicU8 = AtomicU8::new(0);
/// Classes left to the heuristic on the multiway RIVER only (`SOLVER3_ROHNE=drilling/monster`): on dev the
/// river solver bet trips and better less often than live (`FLUSS_WERT`) and lost with them (19.11.).
static RIVER_OHNE: AtomicU8 = AtomicU8::new(0);
/// The same for the multiway FLOP and TURN (`SOLVER3_FOHNE`, `SOLVER3_TOHNE`; owner order 19.11.: no
/// raise->check with trips/monsters as on the river). Default 0.
static FLOP_OHNE: AtomicU8 = AtomicU8::new(0);
static TURN_OHNE: AtomicU8 = AtomicU8::new(0);
/// `SOLVER3_FSPERRE=1`: on the multiway flop facing a bet of at most the pot, a solver fold with top pair or
/// better goes to the heuristic (owner order 19.11., the overfold of 17.11.). Default off.
static FSPERRE: AtomicBool = AtomicBool::new(false);
pub fn set_lage(nur_offen: u8, ohne: u8) {
NUR_OFFEN.store(nur_offen, Ordering::Relaxed);
@@ -44,9 +51,31 @@ pub fn set_river_ohne(ohne: u8) {
RIVER_OHNE.store(ohne, Ordering::Relaxed);
}
/// Per-street classes for the flop and turn (bits as `set_river_ohne`).
pub fn set_strassen_ohne(flop: u8, turn: u8) {
FLOP_OHNE.store(flop, Ordering::Relaxed);
TURN_OHNE.store(turn, Ordering::Relaxed);
}
pub fn set_fsperre(on: bool) {
FSPERRE.store(on, Ordering::Relaxed);
}
fn klassen_env(key: &str) -> u8 {
ohne_bits(&std::env::var(key).unwrap_or_default()).unwrap_or_else(|| panic!("{key}: unknown hand class"))
}
/// `SOLVER3_ROHNE` (class names joined by `/`; an unknown name panics).
pub fn river_ohne_from_env() -> u8 {
ohne_bits(&std::env::var("SOLVER3_ROHNE").unwrap_or_default()).expect("SOLVER3_ROHNE: unknown hand class")
klassen_env("SOLVER3_ROHNE")
}
/// All per-street exclusions and the flop fold lock from the environment (`SOLVER3_FOHNE`, `SOLVER3_TOHNE`,
/// `SOLVER3_ROHNE`, `SOLVER3_FSPERRE`).
pub fn ohne_from_env() {
set_river_ohne(river_ohne_from_env());
set_strassen_ohne(klassen_env("SOLVER3_FOHNE"), klassen_env("SOLVER3_TOHNE"));
set_fsperre(std::env::var("SOLVER3_FSPERRE").as_deref() == Ok("1"));
}
/// `(nur_offen, ohne)` from `SOLVER_FLOP3` / `SOLVER_TURN3` / `SOLVER_RIVER3` = `offen` and
@@ -89,7 +118,12 @@ pub(crate) fn lage_passt(raw: &Spot) -> bool {
if NUR_OFFEN.load(Ordering::Relaxed) & bit != 0 && raw.to_call > 0.0 {
return false;
}
let ohne = OHNE.load(Ordering::Relaxed) | if bit == 4 { RIVER_OHNE.load(Ordering::Relaxed) } else { 0 };
let strasse = match bit {
1 => FLOP_OHNE.load(Ordering::Relaxed),
2 => TURN_OHNE.load(Ordering::Relaxed),
_ => RIVER_OHNE.load(Ordering::Relaxed),
};
let ohne = OHNE.load(Ordering::Relaxed) | strasse;
!(ohne != 0 && raw.hero_cards.len() == 2 && (3..=5).contains(&raw.board.len()) && ohne & (1 << crate::sim::poolruf::klasse(&raw.hero_cards, &raw.board)) != 0)
}
@@ -214,6 +248,16 @@ pub fn solve_multi3(spot: &Spot) -> Option<SolvedM> {
Some(SolvedM { row, acts, iterations: solver.iterations(), millis: started.elapsed().as_secs_f64() * 1e3, players: order.len(), nodes, combos })
}
/// `SOLVER3_FSPERRE`: flop, a bet of at most the pot before it (`pot` includes the bet), top pair or better.
pub(crate) fn fsperre_greift(raw: &Spot) -> bool {
FSPERRE.load(Ordering::Relaxed)
&& raw.street == Street::Flop
&& raw.to_call > 0.0
&& raw.to_call <= raw.pot - raw.to_call + 1e-9
&& raw.hero_cards.len() == 2
&& crate::sim::poolruf::klasse(&raw.hero_cards, &raw.board) >= 3
}
/// The live multiway turn/flop decision, or `None` and the heuristic keeps it.
pub fn multi3_decision(raw: &Spot) -> Option<Decision> {
let on = match raw.street {
@@ -237,6 +281,9 @@ pub fn multi3_decision(raw: &Spot) -> Option<Decision> {
}
}
let act = s.acts[pick];
if act == Act::Fold && fsperre_greift(raw) {
return None;
}
let p = s.row[pick];
let street = if gated.street == Street::Turn { "turn3" } else { "flop3" };
Some(Decision::new(
+25
View File
@@ -161,3 +161,28 @@ fn lage_limits_open_spots_and_classes() {
assert!(crate::sim::poolruf::klasse(&facing.hero_cards, &facing.board) == k || lage_passt(&facing));
set_lage(0, 0);
}
/// Owner order 19.11.: per-street class exclusions on flop/turn and the flop fold lock (top pair or better,
/// bet at most the pot). All off by default.
#[test]
fn strassen_ohne_und_flop_sperre() {
let flop = three_way(Street::Flop, "Ac Kd"); // top pair, 3.75 into 7.5
let k = crate::sim::poolruf::klasse(&flop.hero_cards, &flop.board);
assert_eq!(k, 3);
assert!(lage_passt(&flop));
set_strassen_ohne(1 << k, 0);
assert!(!lage_passt(&flop));
set_strassen_ohne(0, 1 << k);
assert!(lage_passt(&flop), "turn classes leave the flop alone");
set_strassen_ohne(0, 0);
assert!(!fsperre_greift(&flop), "lock off by default");
set_fsperre(true);
assert!(fsperre_greift(&flop));
let mut gross = flop.clone();
gross.to_call = 9.0;
gross.pot = 16.5; // 9 into 7.5: over the pot
assert!(!fsperre_greift(&gross));
assert!(!fsperre_greift(&three_way(Street::Flop, "6s 5d")), "air is not locked");
assert!(!fsperre_greift(&three_way(Street::Turn, "Ac Kd")), "flop only");
set_fsperre(false);
}