Robopoker

repository·main·Indexed 42 days ago

https://github.com/krukah/robopoker

A high-performance Rust implementation of superhuman-scale poker AI aiming for functional parity with Pluribus. It features a complete stack including hand evaluation, hierarchical abstraction, MCCFR training, and real-time subgame solving. The project includes the arena crate for hand history analysis using AIVAT variance reduction, the bouncer crate for JWT and Argon2 authentication, and the daybook crate for managing PostgreSQL schemas for live game data, abstraction pipelines, and training artifacts.

Tokens
103.6K
Snippets
302
Records
444
Agent score
52%

What's inside Robopoker

  1. Overview of robopoker published crates

    main

    The robopoker project is a collection of specialized Rust crates for poker AI research and implementation, focusing on Counterfactual Regret Minimization (CFR) and hand abstraction. Most core components are published to crates.io and can be used as independent libraries.

    Published Crates

    CrateDescription
    pokerkitType aliases, constants, regime/version metadata, action translation, hyperparams! macro
    deuceCard primitives, hand evaluation, equity, strategic abstraction
    mongeOptimal transport (Sinkhorn, EMD) over arbitrary measures
    elkanGeneric, triangle-inequality-accelerated (Elkan 2003) k-means
    lloydHierarchical k-means hand abstraction with EMD
    kickerPoker game engine: state, edges, settlement, witness/perfect recall
    mccfrGame-agnostic MCCFR framework with pluggable regret/policy/sampling
    subgameSafe (world-partitioned) and depth-limited subgame solving
    nlheNo-Limit Hold'em solver and abstraction
    daybookPostgreSQL bulk I/O via Schema/Row/Streamable
    vitalsOpenTelemetry init and a centrally-registered metric table
    robopokerFacade re-exporting the published crates
  2. Overview of spar

    main
    spar is a Slumbot API benchmark client designed for evaluating MCCFR (Monte Carlo Counterfactual Regret Minimization) strategies. It is a component of the robopoker workspace and serves as a tool to benchmark how well specific strategies perform against the Slumbot API.
  3. Overview of subgame solving techniques

    main

    The subgame crate provides safe and depth-limited subgame solving by composing two orthogonal real-time solving techniques: safe subgame solving and depth-limited solving.

    Every real-time solving technique in this project follows the same core principle: re-solve a small game rooted at the current decision point and borrow information (priors, leaf values, opponent range) from a frozen blueprint for everything not being re-solved.

    TechniquePurposeMechanism
    Safe subgameFixes opponent-range leakageUses world partitioning to ensure safety against the opponent's actual distribution via world/
    Depth-limitedFixes tree size issuesUses biased continuation strategies to evaluate leaves at a frontier via depth/
    NestingFixes off-tree actionsSplices in actions not present in the blueprint's abstraction and re-solves via nest/
  4. Overview of the litmus crate

    main
    The litmus crate provides strategic litmus tests used for validating blueprints within the robopoker ecosystem. It features a composable, type-safe scenario catalog. To use these scenarios, a backend (such as a server) must implement a typed Ops trait, which defines the operations available during the test execution.
  5. Overview of lloyd: Hierarchical k-means clustering for poker abstraction

    main

    The lloyd crate implements hierarchical k-means clustering using Earth Mover's Distance (EMD) to create poker hand abstractions. The clustering process follows a street-by-street hierarchy: river → turn → flop → preflop.

    Architecture Workflow

    1. Observations: Starts with isomorphic observations (provided by the deuce crate).
    2. Histograms: Converts observations into equity histograms.
    3. K-Means (Elkan): Performs clustering using the Elkan algorithm.
    4. EMD Metric: Uses either monge or Sinkhorn implementations of the Earth Mover's Distance metric.
    5. Abstraction Buckets: Produces the final abstraction buckets.
    6. Storage: Results are stored in a daybook Postgres database.

    Note that each coarser street clusters over the distributions of the next street's buckets, using the previous street as a prior.

  6. Overview of arena for hand history analysis

    main

    The arena crate is designed for hand history analysis in No-Limit Hold'em. It converts stored hand histories into statistically sound performance estimates by replaying hands through a game engine and applying AIVAT (a variance reduction technique).

    By using a trained MCCFR blueprint as a control variate, arena strips out the luck associated with card deals and action choices. This allows for sharper win-rate estimates and the ability to distinguish real skill from noise using significantly fewer hands than raw win-rate calculations.

  7. Overview of roshambo

    main
    roshambo is a Rock-Paper-Scissors solver designed specifically for validating the MCCFR (Monte Carlo Counterfactual Regret Minimization) framework. It serves as a simplified environment within the robopoker workspace to ensure the correctness of MCCFR implementations before applying them to more complex poker games.
  8. Overview of the deuce card layer

    main

    deuce is the foundational card representation and strategic abstraction layer for the robopoker project. It provides high-performance, branchless bit manipulation for card games.

    Key features include:

    • Efficient Encodings: A Card is represented as a single u8 (0..52), and a Hand is a u64 bitset.
    • Hand Evaluation: Converts hands into a comparable Strength type using bit-twiddling.
    • Suit Isomorphism: Collapses the game's observation space into strategically-distinct equivalence classes by applying suit permutations, reducing the complexity of river observations from billions to approximately 123 million classes.
    • Shortdeck Support: Includes a shortdeck feature to switch the stack to the 36-card variant.
  9. Overview of the phh crate

    main

    The phh crate provides Poker Hand History parsing, chip-exact replay, and a 6-max to 2-max reduction mechanism. It is specifically designed to evaluate heads-up poker blueprints against multiway (6-max) logs, such as the Brown & Sandholm (2019) dataset.

    Key capabilities include:

    • Parsing: Converts TOML hand histories into typed Record objects.
    • Replay: Generates Outcome objects containing finishing stacks and node lists.
    • Reduction: Reduces 6-max hands to heads-up equivalents for tree comparison.
    • Evaluation: Uses an Oracle interface to compare logged decisions against a strategy's policy to estimate exploitability.
  10. Understand the pokerkit core architecture

    main

    The pokerkit crate serves as the foundational shared vocabulary for the robopoker workspace. It provides domain-specific type aliases, runtime configuration management, and the action-translation engine.

    Key components include:

    • Numeric Vocabulary: Thin aliases for f32/i16 types to improve code legibility.
    • Runtime Configuration: A global configuration system using OnceLock keyed by Version and Regime.
    • Action Translation: A mechanism to map raw, arbitrary bet sizes onto a finite, abstract action grid used for training and evaluation.
  11. Use the kuhn crate for MCCFR framework validation

    main
    The kuhn crate provides a Kuhn poker solver specifically designed for validating the MCCFR (Monte Carlo Counterfactual Regret Minimization) framework within the robopoker ecosystem. It serves as a controlled environment to ensure that the core poker engine and training algorithms are functioning correctly by solving a simplified game (Kuhn poker) with known optimal strategies.