百科.dev
全部条目在线工具AI 编程趋势榜开源项目技术资讯提交条目
登录
< 返回工具列表
R

rs-poker

> 编程语言
开源

rs-poker 是一个 Rust 库,其中包含了您需要的所有扑克评估工具,从手牌排名和起始牌枚举到完整的代理比赛场景。

171 stars0 点赞0 次浏览
访问官网GitHub

工具介绍

rs-poker 是一个 Rust 库,其中包含了您需要的所有扑克评估工具,从手牌排名和起始牌枚举到完整的代理比赛场景。

rs-poker

The most advanced open-source poker library available. Hand evaluation at 50M+ hands/sec per core, a CFR solver for game-theory optimal strategy approximation, Omaha support (PLO4-PLO7), multi-agent arena simulation, Monte Carlo equity calculation, and ICM tournament simulation — all in Rust.

Available as both a library (rs_poker) and a CLI binary (rsp).

Quick Start — rsp CLI

Install the binary:

bash
cargo install rs_poker --features rsp

Rank a hand:

bash
rsp holdem rank AcKdQhJsTs

Monte Carlo equity simulation (3M hands by default):

bash
rsp holdem simulate AdKh 8c8s

Calculate outs with board cards:

bash
rsp holdem outs AcAd KsKh --board QhJhTh --detailed

Rank an Omaha hand:

bash
rsp omaha rank AhAsKhKs QhJhTh

Pit agents against each other:

bash
rsp arena compare ./examples/configs -n 5000 -p 3

Generate hand histories in Open Hand History format:

bash
rsp arena generate ./examples/configs -o hands.ohh -n 1000

Convert chipEV to $EV in tournaments:

bash
rsp icm simulate --chip-stacks 1500 1250 600 500 850 800 --payments 50 30 20 --iterations 50000

Library Usage

Add to your project:

bash
cargo add rs_poker

Parse and rank a hand

rust
use rs_poker::core::{FlatHand, Rankable};

let hand = FlatHand::new_from_str("AcKdQhJsTs").unwrap();
let rank = hand.rank();
println!("{}", rank); // Straight

Monte Carlo equity simulation

rust
use rs_poker::core::{Card, Hand, Suit, Value};
use rs_poker::holdem::MonteCarloGame;

let hero = Hand::new_with_cards(vec![
    Card::new(Value::Ace, Suit::Spade),
    Card::new(Value::Ace, Suit::Heart),
]);
let villain = Hand::new_with_cards(vec![
    Card::new(Value::King, Suit::Spade),
    Card::new(Value::King, Suit::Heart),
]);

let mut sim = MonteCarloGame::new(vec![hero, villain]).unwrap();
let equity = sim.estimate_equity(100_000);
// equity[0] ≈ 0.82 (AA vs KK)

Omaha hand evaluation

rust
use rs_poker::core::Rankable;
use rs_poker::omaha::OmahaHand;

let hand = OmahaHand::new_from_str("AhAsKhKs", "QhJhTh").unwrap();
let rank = hand.rank();
println!("{}", rank); // StraightFlush — uses exactly 2 hole + 3 board

Core

Foundational types for all poker variants:

  • Card, Suit, Value — standard 52-card representations
  • Hand — bitset-backed hand with O(1) card operations via CardBitSet (u64)
  • FlatHand — vector-backed hand optimized for ranking
  • Deck — shuffleable deck with dead card support
  • Rank — full hand ranking: HighCard through StraightFlush with accurate kicker comparison
  • Rankable trait — unified ranking API implemented by all hand types
  • PlayerBitSet (u16) — O(1) player tracking for up to 16 players

Performance

Hand evaluation runs at 50M+ hands/sec per core (~20ns per 5-card hand, AgentAction { AgentAction::Call(game_state.current_bet()) } fn name(&self) -> &str { "my-agent" } }

…

bash rsp arena compare ./examples/configs -n 5000 -p 3


Or configure them via JSON:

```json
{
  "type": "cfr_configurable",
  "name": "CFR-Agent",
  "exploration": {
    "max_recursion_depth": 3,
    "act_deadline_ms": 250,
    "budget": { "type": "per_depth_iterations", "counts": [24, 3, 1] }
  },
  "action_config": {
    "preflop": {
      "call_enabled": true,
      "raise_mult": [4.0],
      "pot_mult": [],
      "setup_shove": false,
      "all_in": true
    },
    "flop": {
      "call_enabled": true,
      "raise_mult": [],
      "pot_mult": [0.5, 1.0],
      "setup_shove": false,
      "all_in": true
    }
  }
}

Simulated ICM

Monte Carlo-based ICM (Independent Chip Model) tournament equity calculation.

rust
use rs_poker::simulated_icm::simulate_icm_tournament;

let chip_stacks = vec![10000, 5000, 3000, 2000];
let payments = vec![100, 50, 25, 10];
let winnings = simulate_icm_tournament(&chip_stacks, &payments);
// winnings[i] = expected payout for player i based on chip stack

Avoids the O(N!) complexity of traditional ICM by simulating all-in confrontations. Parallelizable across independent tournaments.

Feature Flags

Flag Default Description
arena Yes Multi-agent simulation framework, CFR solver
serde Yes JSON serialization for hands, game states, configs
omaha Yes Omaha (PLO4/PLO5/PLO6/PLO7) hand evaluation
open-hand-history Yes Open Hand History format import/export
rsp No CLI binary with all features enabled
arena-test-util No Approximate comparison helpers for tests
open-hand-history-test-util No OHH format testing helpers

Testing and Correctness

  • Fuzzing — hand ranking, game simulation replay, CFR agent, and Omaha evaluation all have fuzz targets
  • Mutation testing — cargo-mutants validates test coverage catches real bugs
  • Benchmarks — comprehensive suite covering hand ranking, Monte Carlo simulation, arena games, CFR, ICM, and Omaha

License

Apache-2.0

Issues· 2 开放

查看全部 Issues在 GitHub 打开

暂无开放 Issues,或尚未同步最近议题。

> 标签

Rustarenabotcardscfr

暂无评论,来聊聊你的看法吧

> 工具信息

发布日期2026年8月1日
最后更新2026年9月18日
分类编程语言
定价开源

> 相关工具

T
TypeScript
JavaScript 的超集,为前端与全栈提供静态类型
P
Python
通用编程语言,广泛用于 Web、数据与 AI
G
Go
Google 推出的简洁高效系统语言