106 lines
3.0 KiB
Rust
106 lines
3.0 KiB
Rust
//! Outs: unseen cards (deck of the variant minus hole and board) after which hero's class improves.
|
|
//! Counted: Straight or better for any hand; for one-pair hands also two pair / trips / set
|
|
//! made with a rank hero holds. Board-only improvements and cards that merely pair the board do not count.
|
|
use pokerfreak::card::Card;
|
|
use pokerfreak::read::hand_read::read;
|
|
use pokerfreak::variant::{rules, Variant};
|
|
|
|
fn cs(text: &str) -> Vec<Card> {
|
|
Card::parse_list(text).expect("cards")
|
|
}
|
|
|
|
fn outs(variant: Variant, hole: &str, board: &str) -> u8 {
|
|
read(&rules(variant), &cs(hole), &cs(board)).expect("read").outs
|
|
}
|
|
|
|
fn nl(hole: &str, board: &str) -> u8 {
|
|
outs(Variant::Nlhe, hole, board)
|
|
}
|
|
|
|
#[test]
|
|
fn flush_draw_has_nine_outs_in_a_full_deck() {
|
|
assert_eq!(nl("Ah Kh", "2h 7h Qc"), 9);
|
|
}
|
|
|
|
#[test]
|
|
fn flush_draw_has_five_outs_in_short_deck() {
|
|
// 9 cards per suit, 4 seen. 31 cards unseen instead of 47.
|
|
assert_eq!(outs(Variant::ShortDeck, "Ah Kh", "Qh 9h 7c"), 5);
|
|
assert_eq!(outs(Variant::Nlhe, "Ah Kh", "Qh 9h 7c"), 9);
|
|
}
|
|
|
|
#[test]
|
|
fn open_ended_straight_draw_has_eight_outs() {
|
|
assert_eq!(nl("9h 8c", "7d 6s 2c"), 8);
|
|
}
|
|
|
|
#[test]
|
|
fn short_deck_open_ender_has_eight_outs_among_fewer_cards() {
|
|
// Ts and Js complete 7-J / 6-T? Here the 6 and the J complete 6-T and 7-J; 8 outs of 31 unseen cards.
|
|
assert_eq!(outs(Variant::ShortDeck, "9h 8c", "7d Ts Kc"), 8);
|
|
}
|
|
|
|
#[test]
|
|
fn gutshot_has_four_outs() {
|
|
assert_eq!(nl("9h 7c", "6d 5s Kc"), 4);
|
|
}
|
|
|
|
#[test]
|
|
fn double_gutshot_has_eight_outs() {
|
|
assert_eq!(nl("5h 7c", "3d 6s 9c"), 8);
|
|
}
|
|
|
|
#[test]
|
|
fn flush_plus_open_ender_has_fifteen_outs() {
|
|
// 9 hearts + three non-heart tens + three non-heart fives.
|
|
assert_eq!(nl("9h 8h", "7h 6h 2c"), 15);
|
|
}
|
|
|
|
#[test]
|
|
fn top_pair_good_kicker_has_five_outs() {
|
|
// Three aces (two pair) and two kings (trips). Pairing the seven or deuce does not count.
|
|
assert_eq!(nl("Ah Kd", "Ks 7c 2d"), 5);
|
|
}
|
|
|
|
#[test]
|
|
fn underpair_has_two_outs_to_a_set() {
|
|
assert_eq!(nl("3c 3d", "Kh 9s 5c"), 2);
|
|
}
|
|
|
|
#[test]
|
|
fn board_completed_straight_is_not_an_out() {
|
|
// Fives and tens give the board a straight; hero's deuces add nothing. Only the two deuces make a set.
|
|
assert_eq!(nl("2h 2d", "6c 7s 8d 9h"), 2);
|
|
}
|
|
|
|
#[test]
|
|
fn river_has_no_outs() {
|
|
assert_eq!(nl("Ah 5h", "Kh 9h 2c 7d Jc"), 0);
|
|
assert_eq!(nl("9h 8c", "7d 6s 2c Kd Kc"), 0);
|
|
}
|
|
|
|
#[test]
|
|
fn made_flush_cannot_be_improved_by_a_plain_flush_card() {
|
|
// Ace-high flush made: only full house, quads or straight flush improve it.
|
|
let o = nl("Ah 5h", "Kh 9h 2h");
|
|
assert!(o <= 12, "{o}");
|
|
}
|
|
|
|
#[test]
|
|
fn air_without_draw_has_no_outs() {
|
|
assert_eq!(nl("Ah Kd", "9c 6s 2d"), 0);
|
|
}
|
|
|
|
#[test]
|
|
fn plo5_nut_flush_draw_outs() {
|
|
// Ah 2h in hand (no pair, no straight draw), Kh 7h on the board: nine unseen hearts (no other improvement for this hand).
|
|
assert_eq!(outs(Variant::Plo5, "Ah 2h 3s Qc 8d", "Kh 7h 4c 9d"), 9);
|
|
}
|
|
|
|
#[test]
|
|
fn outs_never_exceed_the_unseen_cards() {
|
|
for (hole, board) in [("Ah Kh", "2h 7h Qc"), ("9h 8h", "7h 6h 2c"), ("7c 7d", "7h Ks 2d")] {
|
|
assert!(nl(hole, board) <= 47);
|
|
}
|
|
}
|