@cloviz/eq-mc

中文文档
0.1.7发布于 2026/06/25MITTypeScriptES Module零依赖近 30 天下载 5117

Poker equity calculator compiled to WebAssembly

原始使用文档
文档目录9 节
  1. Install
  2. Usage
  3. API
  4. calculate_combo_equity(combos, board, deadCards, trials)
  5. calculate_combo_equity_exact(combos, board, deadCards)
  6. calculate_range_equity(ranges, board, deadCards, trials)
  7. load_preflop_hu_table(bytes)
  8. is_preflop_hu_table_loaded()
  9. Packed Preflop HU Table Format

@cloviz/eq-mc

WebAssembly poker equity calculator for Texas Hold'em.

Install

npm install @cloviz/eq-mc

Usage

import init, {
  calculate_combo_equity,
  calculate_combo_equity_exact,
} from "@cloviz/eq-mc"

await init()

const approximate = calculate_combo_equity("AsAh,KsKh", "", "", 100000)
const exact = calculate_combo_equity_exact("AsAh,KsKh", "", "")
const exactWithDeadCards = calculate_combo_equity_exact("AsAh,KsKh", "2c,7d,Ts", "Qc")

console.log({ approximate, exact, exactWithDeadCards })

API

calculate_combo_equity(combos, board, deadCards, trials)

Monte Carlo combo equity.

  • combos: comma-separated combos, for example "AsAh,KsKh"
  • board: comma-separated board cards, for example "2c,7d,Ts", or ""
  • deadCards: comma-separated cards to exclude, for example "Ad,Kc", or ""
  • trials: simulation count
  • returns comma-separated equities, for example "0.826370,0.173630"

calculate_combo_equity_exact(combos, board, deadCards)

Exact combo equity by exhaustive runout enumeration.

  • combos: comma-separated combos
  • board: comma-separated board cards, or ""
  • deadCards: comma-separated cards to exclude, for example "Ad,Kc", or ""
  • returns comma-separated equities

For preflop heads-up exact equity, this API can use an optional packed lookup table loaded with load_preflop_hu_table. Without the table it falls back to the normal exact path.

calculate_range_equity(ranges, board, deadCards, trials)

Monte Carlo range equity.

  • ranges: pipe-separated weighted ranges, for example "AsKs:1.0,AsKh:0.5|QhQd:1.0,QhQc:1.0"
  • board: comma-separated board cards, or ""
  • deadCards: comma-separated cards to exclude, for example "Ad,Kc", or ""
  • trials: simulation count
  • returns comma-separated equities

load_preflop_hu_table(bytes)

Loads an optional packed preflop heads-up exact equity table.

  • bytes: Uint8Array containing the EQPH binary table
  • returns true when the table was loaded, false when it was already loaded or the format is invalid

is_preflop_hu_table_loaded()

Returns whether the optional preflop heads-up table is loaded.

Packed Preflop HU Table Format

The table is intentionally not bundled into the npm package. It is meant to be served by applications that need low-latency preflop heads-up exact equity.

  • header: 16 bytes
  • magic: EQPH
  • version: 1
  • combo count: 1326
  • entries: upper triangle only, excluding identical combo pairs
  • entry size: 6 bytes
  • entry payload: firstWins and chops as little-endian unsigned 24-bit ints
  • total runouts per entry: 1_712_304

The canonical first/second order is the ascending combo-id order. Callers do not need to canonicalize hands before passing them to calculate_combo_equity_exact.

版本与发布记录

@cloviz/eq-mc 共发布 8 个版本,首次发布于 2025/12/23;过去 12 个月发布了 8 个版本。

版本发布日期距今
0.1.7latest2026/06/254 个月前
0.1.62026/06/254 个月前
0.1.52026/06/085 个月前
0.1.42026/06/085 个月前
0.1.32026/06/085 个月前
0.1.22026/06/085 个月前

关于 @cloviz/eq-mc 的常见问题

@cloviz/eq-mc 是什么?

Poker equity calculator compiled to WebAssembly

如何安装 @cloviz/eq-mc?

在项目目录运行 npm install @cloviz/eq-mc,或使用 pnpm add / yarn add / bun add。

@cloviz/eq-mc 支持 TypeScript 吗?

支持。包内自带 TypeScript 类型声明(package.json 声明了 types 入口),安装后即可获得类型提示,无需再安装 @types 包。

@cloviz/eq-mc 支持 ESM 还是 CommonJS?

以 ES Module 形式发布,推荐使用 import 引入。在 CommonJS 项目中,Node.js 20.19+ / 22.12+ 可以直接 require() 不含顶层 await 的 ES Module,更早的版本需要改用动态 import()。

@cloviz/eq-mc 可以商用吗?

@cloviz/eq-mc 使用 MIT 许可。宽松许可:允许商业使用、修改和再分发,通常只需在分发时保留原版权与许可声明。以上为概括,不构成法律意见,请以许可原文为准。

@cloviz/eq-mc 的下载量有多少?

根据 npm 官方下载统计,@cloviz/eq-mc 在 2026/10/10 – 2026/11/08 这 30 天内被下载 5,117 次,日均约 171 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@cloviz/eq-mc 还在维护吗?

最新版本 0.1.7 发布于 2026/06/25(4 个月前);至今共发布 8 个版本,其中过去 12 个月发布了 8 个;首次发布于 2025/12/23。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。