mod spot_fixture; use rechner::engine::postflop::choose_postflop; use rechner::engine::semibluff::has_real_draw; use rechner::exploit::thresholds::Thresholds; use rechner::game::{Choice, Spot, Street}; use rechner::read::draw::Draw; use rechner::read::made::Made; use rechner::read::suit_pattern::SuitPattern; use spot_fixture::*; const BASE: Thresholds = Thresholds::BASE; // round_flop: pot 10, 5 to call, stack 100, candidates [10, 15, 20] (1/3, 2/3, pot). // Share 0.40, heads-up, so realized share is 0.40 and the call needs 1/3 + 0.02. // call EV = 0.40 * 15 - 5 = 1.0 // raise to 20, fe = 2/3*s: fe*10 + (1-fe) * (0.40 * 45 - 20) [final pot 45] // raise to 15, fe = 0.6*s: fe*10 + (1-fe) * (0.40 * 35 - 15) [final pot 35] // raise to 10, fe = 0.5*s: fe*10 + (1-fe) * (0.40 * 25 - 10) [final pot 25] // scale 1.0: raise to 20 = 6.667 - 0.667 = 6.0 (beats the call by 5.0) // scale 0.15: 10 -> 0.75, 15 -> -0.01, 20 -> -0.80, all below the call's 1.0. #[test] fn flush_draw_with_good_fold_equity_raises() { let d = choose_postflop(&round_flop(), &estimate(0.40, 0.005), &BASE, &flush_draw_read()); assert_eq!(d.choice, Choice::Raise { to: 20.0 }, "{d:?}"); assert!(d.reason.contains("semibluff"), "{}", d.reason); assert!(d.reason.contains("flush draw"), "{}", d.reason); } #[test] fn the_same_draw_only_calls_against_a_calling_station() { let station = Thresholds { fold_equity_scale: 0.15, ..BASE }; let d = choose_postflop(&round_flop(), &estimate(0.40, 0.005), &station, &flush_draw_read()); assert_eq!(d.choice, Choice::Call, "{d:?}"); } #[test] fn no_semibluff_on_the_river() { let river = Spot { street: Street::River, ..round_flop() }; let d = choose_postflop(&river, &estimate(0.40, 0.005), &BASE, &flush_draw_read()); assert_eq!(d.choice, Choice::Call, "{d:?}"); } #[test] fn pure_bluffs_without_equity_stay_off() { let air = read_of(Made::Air, Draw::None, 0, SuitPattern::Rainbow, 0.2); let th = Thresholds { abstain_band: 0.0, ..BASE }; let d = choose_postflop(&round_flop(), &estimate(0.40, 0.0), &th, &air); assert_eq!(d.choice, Choice::Call, "{d:?}"); // Even a hopeless hand never turns into a bluff raise. let d = choose_postflop(&round_flop(), &estimate(0.10, 0.0), &th, &air); assert_eq!(d.choice, Choice::Fold, "{d:?}"); } #[test] fn eight_outs_count_as_a_real_draw_even_for_a_gutshot_class() { let eight = read_of(Made::Air, Draw::Gutshot, 8, SuitPattern::Rainbow, 0.2); let seven = read_of(Made::Air, Draw::Gutshot, 7, SuitPattern::Rainbow, 0.2); let d8 = choose_postflop(&round_flop(), &estimate(0.40, 0.005), &BASE, &eight); let d7 = choose_postflop(&round_flop(), &estimate(0.40, 0.005), &BASE, &seven); assert!(matches!(d8.choice, Choice::Raise { .. }), "{d8:?}"); assert_eq!(d7.choice, Choice::Call, "{d7:?}"); } #[test] fn which_reads_are_real_draws() { let r = |draw, outs| read_of(Made::Air, draw, outs, SuitPattern::Rainbow, 0.2); for draw in [Draw::OpenEnded, Draw::Flush, Draw::Combo] { assert!(has_real_draw(&r(draw, 0), Street::Flop), "{draw:?}"); assert!(!has_real_draw(&r(draw, 9), Street::River), "{draw:?}"); } assert!(has_real_draw(&r(Draw::None, 8), Street::Turn)); assert!(!has_real_draw(&r(Draw::None, 7), Street::Turn)); assert!(!has_real_draw(&r(Draw::Backdoor, 3), Street::Flop)); assert!(!has_real_draw(&r(Draw::Gutshot, 4), Street::Flop)); } #[test] fn a_semibluff_is_also_possible_when_the_raise_is_the_only_way_to_continue_cheaply() { // Free to act: check is the passive option (EV share * pot = 4.0 at 0.40). let spot = Spot { to_call: 0.0, legal: vec![rechner::game::ActionKind::Check, rechner::game::ActionKind::Raise], ..round_flop() }; let d = choose_postflop(&spot, &estimate(0.40, 0.005), &BASE, &flush_draw_read()); assert!(matches!(d.choice, Choice::Raise { .. }), "{d:?}"); } #[test] fn board_only_never_raises_even_with_a_huge_share() { let board = read_of(Made::BoardOnly, Draw::None, 0, SuitPattern::Rainbow, 0.0); let d = choose_postflop(&round_flop(), &estimate(0.95, 0.002), &BASE, &board); assert_eq!(d.choice, Choice::Call, "{d:?}"); }