chironaut 0.3.5

A poker game library for Texas Hold'em and other poker variants
Documentation
use chironaut::Game;
use chironaut::rules::{GameRules, AnteStructure};

fn main() {
    println!("Testing Different Ante Structures\n");
    
    // Test 1: Fixed ante for all players
    println!("=== TEST 1: FIXED ANTE ===");
    test_ante_structure(GameRules::nlhe(5, 10).with_ante(2));
    
    // Test 2: Big blind ante (only BB posts)
    println!("\n=== TEST 2: BIG BLIND ANTE ===");
    test_ante_structure(GameRules::nlhe(5, 10).with_bb_ante(20));
    
    // Test 3: Button ante (only dealer posts)
    println!("\n=== TEST 3: BUTTON ANTE ===");
    test_ante_structure(GameRules::nlhe(5, 10).with_button_ante(15));
    
    // Test 4: Percentage-based ante
    println!("\n=== TEST 4: PERCENTAGE ANTE (20% of BB) ===");
    test_ante_structure(GameRules::nlhe(5, 10).with_percentage_ante(20));

    // Test 5: No ante (default)
    println!("\n=== TEST 5: NO ANTE ===");
    test_ante_structure(GameRules::nlhe(5, 10));
}

fn test_ante_structure(rules: GameRules) {
    println!("Game Rules: {}/{} {}", 
             rules.small_blind, 
             rules.big_blind, 
             rules.ante_structure);
    
    // Calculate ante amount
    let ante_amount = rules.calculate_ante_amount();
    println!("Calculated ante amount: {}", ante_amount);
    
    // Create a game with this ante structure
    let mut game = Game::new(rules);
    
    // Add 5 players with 100 chips each
    for i in 0..5 {
        game.add_player(format!("Player {}", i+1), 100).unwrap();
    }
    
    // Start a hand
    game.start_hand().unwrap();
    
    // Display player chip counts after antes are posted
    println!("\nPlayer chip counts after blinds and antes:");
    let mut total_pot = 0;
    for (i, player) in game.players.iter().enumerate() {
        println!("Player {}: {} chips (bet: {})", 
                 i+1, player.chips, player.bet_amount);
        total_pot += player.bet_amount;
    }
    
    // Verify pot size
    println!("\nPot size: {}", game.pot);
    println!("Sum of player bets: {}", total_pot);
    if game.pot != total_pot {
        println!("ERROR: Pot size doesn't match sum of bets!");
    } else {
        println!("Pot size matches sum of bets ✓");
    }
    
    // Show player positions
    println!("\nPositions:");
    println!("Dealer: Player {}", game.dealer_position + 1);
    println!("First to act: Player {}", game.current_position + 1);
    println!("Current bet: {}", game.current_bet);
}