Fix supersonic evaluator and documentation examples
- Remove debug_assert(false) from supersonic evaluator - Disable buggy supersonic generator - Fix documentation examples in README.md and holdem_core/README.md
This commit is contained in:
parent
2da48d43fb
commit
912445d992
3 changed files with 82 additions and 94 deletions
85
README.md
85
README.md
|
|
@ -161,26 +161,27 @@ The evaluator recognizes all standard poker hand types:
|
|||
### Texas Hold'em Bot Analysis
|
||||
|
||||
```rust
|
||||
use holdem_core::hand_evaluator::LookupHandEvaluator;
|
||||
use holdem_core::api::{card::Card, hand::Hand};
|
||||
use holdem_core::{Card, Hand, HoleCards, Board, Evaluator};
|
||||
use std::str::FromStr;
|
||||
|
||||
let evaluator = LookupHandEvaluator::new().unwrap();
|
||||
let evaluator = Evaluator::new().unwrap();
|
||||
|
||||
// Bot analyzes hole cards + flop for decision making
|
||||
let hole_card1 = Card::from_string("As").unwrap().index() as u32;
|
||||
let hole_card2 = Card::from_string("Ks").unwrap().index() as u32;
|
||||
|
||||
let mut board = Hand::new();
|
||||
board.add_card(Card::from_string("Td").unwrap()).unwrap();
|
||||
board.add_card(Card::from_string("Jc").unwrap()).unwrap();
|
||||
board.add_card(Card::from_string("Qh").unwrap()).unwrap();
|
||||
let hole_cards = HoleCards::from_notation("AKs").unwrap();
|
||||
let board = Board::new()
|
||||
.with_flop([
|
||||
Card::from_str("Td").unwrap(),
|
||||
Card::from_str("Jc").unwrap(),
|
||||
Card::from_str("Qh").unwrap(),
|
||||
]).unwrap();
|
||||
|
||||
// Bot evaluates complete hand strength
|
||||
let hand_strength = evaluator.rank_hand_with_hole_cards(hole_card1, hole_card2, &board);
|
||||
println!("Hand strength after flop: {}", hand_strength);
|
||||
let hand = Hand::from_hole_cards_and_board(&hole_cards, &board).unwrap();
|
||||
let hand_value = evaluator.evaluate_hand(&hand);
|
||||
println!("Hand strength after flop: {:?}", hand_value.rank);
|
||||
|
||||
// Bot uses this for post-flop decision making
|
||||
if hand_strength < 2000 { // Strong hand
|
||||
if hand_value.rank as u8 >= 4 { // Straight or better
|
||||
println!("Bot: Continuing with strong hand");
|
||||
}
|
||||
```
|
||||
|
|
@ -188,25 +189,22 @@ if hand_strength < 2000 { // Strong hand
|
|||
### Bot Range Analysis
|
||||
|
||||
```rust
|
||||
use holdem_core::hand_evaluator::LookupHandEvaluator;
|
||||
use holdem_core::api::card::Card;
|
||||
use holdem_core::{Card, Hand, Evaluator};
|
||||
use std::str::FromStr;
|
||||
|
||||
let evaluator = LookupHandEvaluator::new().unwrap();
|
||||
let evaluator = Evaluator::new().unwrap();
|
||||
|
||||
// Bot analyzes range of starting hands for pre-flop strategy
|
||||
let premium_hands = vec![
|
||||
(Card::from_string("AA").unwrap(), Card::from_string("KK").unwrap()),
|
||||
(Card::from_string("QQ").unwrap(), Card::from_string("JJ").unwrap()),
|
||||
(Card::from_string("AK").unwrap(), Card::from_string("AQ").unwrap()),
|
||||
Hand::from_notation("As Ah").unwrap(),
|
||||
Hand::from_notation("Ks Kh").unwrap(),
|
||||
Hand::from_notation("Qs Qh").unwrap(),
|
||||
Hand::from_notation("As Ks").unwrap(),
|
||||
];
|
||||
|
||||
for (card1, card2) in premium_hands {
|
||||
let mut hand = Hand::new();
|
||||
hand.add_card(card1).unwrap();
|
||||
hand.add_card(card2).unwrap();
|
||||
|
||||
let strength = evaluator.rank_hand(&hand);
|
||||
println!("Bot range analysis - {}: {}", hand.to_string(), strength);
|
||||
for hand in premium_hands {
|
||||
let hand_value = evaluator.evaluate_hand(&hand);
|
||||
println!("Bot range analysis - {}: {:?}", hand, hand_value.rank);
|
||||
}
|
||||
```
|
||||
|
||||
|
|
@ -215,29 +213,26 @@ for (card1, card2) in premium_hands {
|
|||
### 7-Card Hand Evaluation for Bot Testing
|
||||
|
||||
```rust
|
||||
use holdem_core::hand_evaluator::LookupHandEvaluator;
|
||||
use holdem_core::api::card::Card;
|
||||
use holdem_core::{Card, Hand, HoleCards, Board, Evaluator};
|
||||
use std::str::FromStr;
|
||||
|
||||
let evaluator = LookupHandEvaluator::new().unwrap();
|
||||
let evaluator = Evaluator::new().unwrap();
|
||||
|
||||
// Texas Hold'em complete hand: 2 hole cards + 5 community cards
|
||||
let hole_cards = [
|
||||
Card::from_string("As").unwrap().index(),
|
||||
Card::from_string("Ks").unwrap().index(),
|
||||
];
|
||||
let hole_cards = HoleCards::from_notation("AKs").unwrap();
|
||||
let board = Board::new()
|
||||
.with_flop([
|
||||
Card::from_str("Td").unwrap(),
|
||||
Card::from_str("Jc").unwrap(),
|
||||
Card::from_str("Qh").unwrap(),
|
||||
]).unwrap()
|
||||
.with_turn(Card::from_str("9s").unwrap()).unwrap()
|
||||
.with_river(Card::from_str("2d").unwrap()).unwrap();
|
||||
|
||||
let community_cards = [
|
||||
Card::from_string("Td").unwrap().index(),
|
||||
Card::from_string("Jc").unwrap().index(),
|
||||
Card::from_string("Qh").unwrap().index(),
|
||||
Card::from_string("9s").unwrap().index(),
|
||||
Card::from_string("2d").unwrap().index(),
|
||||
];
|
||||
|
||||
// Bot evaluates best possible hand from all cards
|
||||
let all_cards: Vec<u32> = hole_cards.iter().chain(community_cards.iter()).cloned().collect();
|
||||
let best_rank = evaluator.rank_hand7(&all_cards);
|
||||
println!("Bot best hand rank: {}", best_rank);
|
||||
// Bot evaluates best possible hand from all 7 cards
|
||||
let hand = Hand::from_hole_cards_and_board(&hole_cards, &board).unwrap();
|
||||
let hand_value = evaluator.evaluate_hand(&hand);
|
||||
println!("Bot best hand rank: {:?}", hand_value.rank);
|
||||
```
|
||||
|
||||
## Testing
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue