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)
This commit is contained in:
Jan-Peter von Hunnius 2026-05-25 11:10:52 +02:00
parent f81f0579d1
commit 09a0777f96
36 changed files with 6565 additions and 4934 deletions

View file

@ -1,11 +1,12 @@
# Math Library - High-Performance Poker Hand Evaluation
A state-of-the-art Rust library for ultra-fast poker hand evaluation using precomputed lookup tables (LUT). This library implements Cactus Kev's perfect hash algorithm to provide sub-microsecond hand evaluation for Texas Hold'em poker hands.
A state-of-the-art Rust library for ultra-fast poker hand evaluation using Cactus Kev's perfect hash algorithm. This library provides sub-microsecond hand evaluation for Texas Hold'em poker hands with a tiny memory footprint (~100 KB for lookup tables).
## 🚀 Features
- **Ultra-Fast Evaluation**: Sub-microsecond hand evaluation using perfect hashing
- **Memory Efficient**: Optimized lookup tables with atomic file I/O operations
- **Ultra-Fast Evaluation**: Sub-microsecond hand evaluation using Cactus Kev perfect hashing
- **Memory Efficient**: Only ~100 KB for lookup tables (7,462 entries) — no multi-GB trie
- **Zero Collisions**: Validated against all 2,598,960 five-card hands
- **Thread Safe**: Singleton pattern with lazy initialization for shared resources
- **Mathematically Correct**: Comprehensive property-based testing and validation
- **Persistent Storage**: Automatic table generation and file-based persistence
@ -14,22 +15,28 @@ A state-of-the-art Rust library for ultra-fast poker hand evaluation using preco
## 📈 Performance
### Hand Evaluation Speed
- **5-card hands**: 50-100 nanoseconds (10-20 million hands/second)
- **6-card hands**: 300-500 nanoseconds (2-3 million hands/second)
- **7-card hands**: 1-2 microseconds (500,000-1 million hands/second)
- **5-card hands**: O(1) — single prime-product hash → table lookup (~50-100 ns)
- **6-card hands**: O(6) — six 5-card lookups (~300-500 ns)
- **7-card hands**: O(1) amortized — `HashMap` cache hit; O(21) on cache miss (~1-2 µs)
### Memory Usage
- **5-card table**: ~10 MB (2.6M entries)
- **6-card table**: ~80 MB (20.4M entries)
- **7-card table**: ~535 MB (133.8M entries)
- **Total system**: ~625 MB for complete evaluation capability
- **Cactus Kev tables**: ~30 KB (1,287 flush + 6,175 unsuited entries = 7,462 total)
- **7-card cache**: Variable — grows with unique hands seen (amortized O(1) lookups)
- **Total base footprint**: ~100 KB (vs. previous ~130 MB trie approach)
## 🏗️ Architecture
The library is organized into several key modules:
The library uses a **Cactus Kev perfect hash** algorithm for 5-card evaluation and a **caching enumeration** strategy for 7-card hands:
- [`evaluator`] - Core hand evaluation engine with lookup table management
- [`evaluator::tables`] - Lookup table structures and perfect hash implementation
- **5-card evaluation**: O(1) via prime-product hashing into two small tables (7,462 entries total, ~30 KB). Each rank maps to a prime; the product of 5 primes uniquely identifies the hand. Zero collisions, validated against all 2,598,960 hands.
- **7-card evaluation**: Amortized O(1) via C(7,5)=21 enumeration over the 5-card tables, with a `HashMap` cache keyed by the product of 52 distinct card primes.
Key modules:
- [`evaluator`] - Core hand evaluation engine with public `Evaluator` API
- [`evaluator::cactus_kev`] - Cactus Kev perfect-hash 5-card evaluator
- [`evaluator::tables`] - `JumpTable` wrapper around Cactus Kev + 7-card cache
- [`evaluator::algorithmic_evaluator`] - Rule-based evaluator (correctness oracle)
- [`evaluator::singleton`] - Thread-safe singleton pattern for shared evaluator instance
- [`evaluator::file_io`] - Atomic file operations with checksum validation
- [`evaluator::integration`] - Integration utilities for holdem_core types
@ -105,10 +112,11 @@ holdem_core = { path = "./holdem_core" }
- **[Benchmarks](math/src/evaluator/benchmarks.rs)** - Performance characteristics
### Module Documentation
- **[Evaluator Module](math/src/evaluator.rs)** - Core evaluation engine
- **[Tables Module](math/src/evaluator/tables.rs)** - Lookup table implementation
- **[File I/O Module](math/src/evaluator/file_io.rs)** - Persistent storage
- **[Integration Module](math/src/evaluator/integration.rs)** - holdem_core integration
- **[Evaluator Module](src/evaluator/evaluator.rs)** - Core evaluation engine and public API
- **[Cactus Kev Module](src/evaluator/cactus_kev.rs)** - 5-card perfect hash evaluator
- **[Tables Module](src/evaluator/tables.rs)** - JumpTable with Cactus Kev + 7-card cache
- **[File I/O Module](src/evaluator/file_io.rs)** - Persistent storage
- **[Integration Module](src/evaluator/integration.rs)** - holdem_core integration
## 🧪 Testing
@ -258,9 +266,9 @@ Run the built-in benchmarks to verify performance:
cargo test benchmarks -- --nocapture
# Expected output:
# 5-card evaluation: 15,000,000 hands/second
# 7-card evaluation: 800,000 hands/second
# Memory usage: 625 MB
# 5-card evaluation: ~10-20 million hands/second
# 7-card evaluation: ~500K-1 million hands/second (amortized with cache)
# Memory usage: ~100 KB base (tables) + variable cache
```
## 🤝 Integration with holdem_core