Commit graph

33 commits

Author SHA1 Message Date
b9963bfbb1 feat(sim): cash_out_threshold — rathole stack excess to bankroll
After each hand, stack above the threshold moves to the bankroll.
Bounds effective depth while keeping natural short-stack dynamics
(losses, rebuy cycles). Needed for realistic deep-stack-safe
benchmarks: the oracle hybrid's EV collapses with stack depth
(+6.9 at 75BB reset vs -33.8 natural), so unbounded natural-stack
snowballs distort candidate evaluation.
2026-09-08 16:23:08 +02:00
a589acbbc7 fix(tests): add max_raises: None to BetLimitConfig test literals 2026-09-07 19:19:31 +02:00
5a8a194be3 fix: make register_bot_type idempotent (skip instead of panic on duplicate)
Prevents test panics when multiple strategies register the same bot type
in parallel test threads.
2026-07-17 07:20:19 +02:00
e5e56fd772 chore: gitignore AGENTS.md (project-local file) 2026-07-06 08:23:15 +02:00
d00df65a98 fix: seat restoration + chip refund on hand error, NoLimit max_raises
Critical fix: complete_hand() now restores seats when run_to_completion()
fails, preventing silent NotEnoughPlayers termination that killed
simulations at random seeds. Wagered chips are refunded before reset to
prevent chip destruction on error path.

Also adds max_raises: Option<usize> to BetLimit::NoLimit, propagated
across all game/bot/tournament construction sites.

NotEnoughPlayers now logs a warning with hand count instead of silently
breaking the simulation loop.
2026-07-06 08:07:38 +02:00
edf8d7ae3f feat: simulation resilience + flock_bot raise safety + trait extensions
- simulation.rs: RaiseBelowMinimum/InsufficientChips now skip hand
  instead of crashing entire simulation. Hands skipped are NOT counted
  in total_hands (accurate player stats).
- flock_bot.rs: Premium preflop raise falls back to Call when stack
  cannot afford minimum raise, preventing illegal AllIn edge cases.
- Added shutdown(), showdown_event() trait methods to HoldemPlayer.
- Added external_id, table_id to GameInfo/PlayerInfo.
- Strategy trait: added save_state() for graceful profile persistence.
2026-06-28 07:11:56 +02:00
05db24f670 chore: remove gitignored REFERENCES.md, moved to Joplin 2026-05-31 12:02:37 +02:00
ed911e3c3a test: add exhaustive multi-threaded 7-card correctness test across all three evaluators 2026-05-30 15:26:54 +02:00
458b8af580 fix: rewrite Supersonic LUT generator, wire evaluator chain, parallelize tournaments
- Rewrite generate_tables() with HashMap-based BFS instead of broken
  sentinel-loop sorted array approach. The old generator used a
  zero-terminated loop that stopped prematurely when mid-array key
  insertions left gaps, producing invalid trie pointers.

- Re-enable auto-generation in load_or_generate() since the generator
  now works correctly (verified by exhaustive C(52,5) correctness test).

- Wire HandRunner::showdown() through Evaluator::instance() instead of
  calling AlgorithmicEvaluator directly, giving access to the full
  3-tier cascade (Supersonic -> Cactus Kev -> Algorithmic).

- Parallelize tournament series loop with rayon for multi-core speedup.

- Remove dead insert_key function and test (unused after generator rewrite).

- Fix tautological benchmark assertion in integration tests.
2026-05-30 12:55:11 +02:00
a46a800d11 feat: align num_raises with Meerkat semantics and add voluntary_raises() helper
- Change GameInfo.num_raises to use Meerkat convention where BB counts
  as the first raise preflop (subtract 1 for SB only, not 2)
- Add GameInfo::voluntary_raises() for Fixed-Limit cap enforcement
- Update flock_bot, raise_bot, and random_bot to use voluntary_raises()
  for can_raise() checks
- Add Evaluator::supersonic() accessor for incremental trie API
- Update documentation across betting.rs, game_info.rs, hand_runner.rs,
  and README.md to clarify the two counting conventions
2026-05-27 18:44:29 +02:00
156904f2bf feat: add incremental trie lookup API and Deck::without_cards
- Add TrieCursor struct for partial Supersonic LUT trie traversal
- Add init_lookup/advance_lookup/finish_* methods for 5/6/7-card incremental eval
- Add raw_init/raw_advance/raw_finish_* zero-cost API (no depth tracking)
- Add Deck::without_cards() for constructing remaining decks
- Re-export TrieCursor from evaluator module
- Add comprehensive tests for all new APIs
- Update .gitignore for docs/REFERENCES.md
2026-05-25 19:44:21 +02:00
912445d992 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
2026-05-25 14:30:16 +02:00
2da48d43fb refactor: remove strategy framework from holdem_core
Remove the entire strategy module (StrategyBot, ModularStrategy,
StrategyContext, ActionRecorder, HandAnalyzer, HandHelper) from
holdem_core. Strategy implementations will live in external crates
(e.g., super_marvin) and register via bot_factory::register_bot_type.

- Delete holdem_core/src/game/strategy/ (6 files, ~1900 lines)
- Delete holdem_core/src/game/bots/strategy_bot.rs
- Remove strategy_bot from bots/mod.rs module declarations and re-exports
- Update bot_factory.rs doc example to show generic custom bot pattern
2026-05-25 12:47:47 +02:00
14c56485e7 docs: clean up documentation - remove obsolete architecture docs, simplify roadmap and vision, update READMEs
- Delete ARCHITECTURE_HAND_LOGGING_TOURNAMENT_IMPROVEMENTS.md (implemented)
- Delete ARCHITECTURE_SUPERSONIC_EVALUATOR.md (implemented)
- Delete REFERENCES.md (no longer needed)
- Simplify ROADMAP.md: remove Phases 4-7 (live server, advanced bots)
- Simplify VISION.md: focus on simulation testbed only
- Update README.md: dual evaluator architecture, fix broken links
- Update holdem_core/README.md: fix title, add Supersonic evaluator docs
2026-05-25 12:19:44 +02:00
09a0777f96 feat: Supersonic evaluator, Cactus Kev hash, repo split cleanup
Evaluator overhaul:
- Add Supersonic LUT trie evaluator (32M-entry, O(n) hand evaluation)
- Add Cactus Kev perfect-hash 5-card evaluator (prime-product hashing)
- 3-tier evaluation priority: Supersonic → Cactus Kev → Algorithmic
- DashMap-cached 7-card evaluation for lock-free concurrent access
- Rewrite JumpTable around CactusKevEvaluator + DashMap cache

Bot framework:
- Add StrategyBot adapter (Strategy trait → HoldemPlayer)
- Add register_bot_type() for plugin-style bot registration
- Add strategy module with modular composable strategies

Repository split:
- Remove holdem_bots from workspace (moved to private super_marvin repo)
- Remove holdem_bots dependency from holdem_sim
- Update cash_game.toml to use built-in bots only
- Clean up .gitignore (remove stale holdem_bots exclusion)
- Delete plans/ directory (internal planning artifacts)

Documentation:
- Add ARCHITECTURE_SUPERSONIC_EVALUATOR.md
- Add REFERENCES.md
- Update ROADMAP.md and VISION.md
- Remove outdated docs (ACHIEVEMENTS, RAKE, TOURNAMENT_RAKE, meerkat-alignment)
2026-05-25 11:10:52 +02:00
f81f0579d1 feat: port Java Supersonic bot framework and cash game bots to Rust
Framework (holdem_core::game::strategy):
- HandAnalyzer: 15 hand analysis methods (overpair, flush draw, OESD, outs, etc.)
- HandHelper: 14 board texture and hand strength methods (Kill Phil grouping, etc.)
- ActionRecorder: per-street action tracking with player filtering
- StrategyContext: read-only game state snapshot with position/pot odds helpers
- Strategy trait + ModularStrategy: composite pattern with 3 voting modes
  (FirstApplicable, Democratic, Random)

Cash Game Bots (holdem_bots crate — private, exclude from public mirrors):
- PostFlopStrategy: shared postflop logic using hand strength approximation
- BigStackBot: NL cash strategy for stack > 25 BB (preflop + postflop)
- ShortStackBot: NL cash strategy for stack ≤ 25 BB (preflop + postflop)
- Full preflop decision trees ported from Java Supersonic framework

Repository restructuring:
- Created holdem_bots crate with feature-gated dependency from holdem_sim
- Added game::strategy module to holdem_core
- Cleaned up 4 unused evaluator stubs
- Moved plans/ to docs/, added proptest-regressions/ to .gitignore
- Added ARCHITECTURE_BOT_FRAMEWORK.md documentation

Tests: 58 new strategy tests + 17 bot tests (all passing)
2026-05-22 16:50:11 +02:00
7c79ae4966 feat: tournament rake, percentage-based prizes, and finish position fixes
- Add tournament_rake_percentage field to GameConfig (house share of entry fees)
- Convert prize structure from absolute amounts to percentages of prize pool
- Fix finish position calculation for tournament eliminations (was inverted)
- Add batch bustout processing for multi-table tournaments (shared positions)
- Add max_rebuys field and rebuy_count tracking on Seat
- Add PrizeStructure::with_rake() and rake_amount field
- Accumulate stats across tournament series (hands, rake, profit)
- Add best_finish and prize_won fields to PlayerStats
- Replace floating-point prize math with integer arithmetic (chip conservation)
- Add comprehensive tests for prize distribution and finish positions
- Update config examples to use percentage-based prizes with rake
- Add ARCHITECTURE_TOURNAMENT_RAKE.md documentation
2026-05-22 14:32:24 +02:00
c041cde3fe feat: hand history logging, tournament series, MTT consolidation, Meerkat API
Major changes:
- Add hand history module (iPoker format) with HandHistoryLogger
- Add run_sng_series() for multi-tournament aggregate statistics
- Fix MTT table consolidation deadlock (sub-minimum-player tables)
- Add Meerkat-compatible convenience methods on Action and GameInfo
- Add custom blind levels, prize structures, auto-rebuy to GameConfig
- Add SngSeriesResult/SngPlayerSeriesResult for series tracking
- Add Tournament::winner(), tables_mut(), shuffle_seats()

Review fixes:
- Fix TOML prizes field ordering (must precede [[game.blind_levels]])
- Add sensible serde defaults for small_blind (10) and big_blind (20)
- Fix prize assignment in run_sng_series (use raw_placement directly)
- Handle hand history filename collisions with suffixed retry
- Add debug_assert guard on collect_hand_history_data double-consumption
2026-05-20 21:05:22 +02:00
9dfd9c3ee3 feat: add rake, bankroll management, seat randomization, FlockBot & ChumpBot
- Add RakeConfig with percentage-based rake and per-pot cap
- Add bankroll tracking (reset per hand or auto-refill threshold)
- Add seat randomization with seeded RNG for reproducibility
- Add FlockBot (tight-aggressive) and ChumpBot (loose-passive) bots
- Refactor HandRunner: extract finalize_result, compute_chip_movements, credit_winnings
- Add num_raises to GameInfo for authoritative raise counting
- Record SB/BB as Raise actions (Meerkat convention)
- Update all existing bot tests for new GameInfo fields
- Add ARCHITECTURE_RAKE_BANKROLL_SEATS.md documentation
2026-05-18 20:44:08 +02:00
17d0440c86 feat: refactor AlgorithmicEvaluator to stateless, add game engine module and holdem_sim CLI
- Refactor AlgorithmicEvaluator from stateful Arc<Evaluator> wrapper to
  pure stateless evaluator with zero-allocation construction
- Extract shared evaluation logic into pub(crate) methods, eliminating
  ~220 lines of duplicated code from Evaluator
- Add game module: table, hand runner, tournament, bots, config, stats
- Add holdem_sim CLI binary crate for running simulations
- Convert MathEvaluator to thread-safe singleton with Arc<Inner> pattern
- Replace heap-allocated combination generation with const-generics
  stack-based approach in AlgorithmicEvaluator::evaluate_n_card_hand
- Add thiserror 2 dependency for GameError derive
- Update docs: README, ACHIEVEMENTS, ROADMAP
2026-05-18 15:12:34 +02:00
dd605e8a66 feat: add AlgorithmicEvaluator, migrate to log crate, fix flush value calculation
- Add AlgorithmicEvaluator wrapper for direct hand evaluation without
  lookup tables, with proper Result-based error handling
- Replace all println! and #[cfg(debug_assertions)] debug output with
  log crate macros (log::info!, log::debug!, log::warn!)
- Fix calculate_flush_value to use base-13 encoding for unique flush
  hand values instead of simple linear sum
- Fix is_straight to use cleaner control flow for regular and wheel
  straight detection
- Remove jump table HighCard/value=0 guard in evaluate_5_card to
  simplify evaluation path
- Add evaluate_n_card_hand_public as pub(crate) for AlgorithmicEvaluator
- Add .gitignore to exclude target/ and .idea/ from version control
- Add comprehensive tests for AlgorithmicEvaluator (14 test cases)
- Update README with new API usage examples
- Add log dependency to Cargo.toml
- Add placeholder modules for future implementations (tables_new,
  benchmark_utils, integration_utils, test_utils)
2026-05-11 20:22:32 +02:00
51e1f58ef9 Fixed hand evaluator LUT generation 2025-11-16 16:02:26 +01:00
7819b1ee27 New evaluator that uses only 133 MB of memory and improves performance of 6- and 7-card hand evaluations 2025-10-11 20:30:50 +02:00
696bf46555 Added hand evaluator
We have test errors currently.
2025-10-11 08:25:46 +02:00
e94bf42dce Holdem basic core structures from scratch. 2025-10-10 19:48:24 +02:00
f02c35bef3 Corrected hand evaluator 2025-10-03 22:46:13 +02:00
e22f2cca0f Corrected hand evaluator based on Java implementation 2025-10-03 21:43:35 +02:00
7ff520ca20 Documented code
Added test cases
2025-10-03 20:22:45 +02:00
5c271b279f Added Documentation
Added Test Cases
Added Comments
2025-10-02 18:33:31 +02:00
ac25a1caea Implemented hand and deck 2025-02-13 17:31:39 +01:00
77315c79b0 Cargo files 2025-02-13 11:56:49 +01:00
52deab3a48 Initial setup of API test 2025-02-13 11:53:22 +01:00
Jan-Peter von Hunnius
4b516c699f Initial README file 2025-02-13 09:23:01 +01:00