Files
pokerfreak/src/read/nut_draw.rs
T

21 lines
798 B
Rust

//! Nut flush draw: hero holds the highest card of the suit that is not on the board
//! (the ace, or the next one down when the ace is on the board).
use super::census::{bit, top_pip, Census};
use super::draw::Draw;
use super::flush_draw::flush_draw_suits;
use super::windows::deck_mask;
use crate::variant::Rules;
pub fn nut_draw(rules: &Rules, census: &Census, draw: Draw) -> bool {
matches!(draw, Draw::Flush | Draw::Combo)
&& (0..4usize)
.filter(|s| flush_draw_suits(rules.hole_usage, census) >> s & 1 == 1)
.any(|s| holds_best_missing(rules, census, s))
}
fn holds_best_missing(rules: &Rules, census: &Census, suit: usize) -> bool {
let free = deck_mask(rules.deck) & !census.board_suit[suit];
census.hole_suit[suit] & bit(top_pip(free)) != 0
}