โญ Star on GitHub
๐Ÿ“ฆ @pokerpocket/engine
๐Ÿง  Pure reducer core

PokerPocket

Fast, deterministic Texas Hold'em reducer for JavaScript and TypeScript. Zero runtime dependencies, plug into any loop or UI.

$
npm install @pokerpocket/engine
โœ“ Deterministic RNG snapshots
โœ“ Batteries-included CLI
โœ“ Works offline, no deps
import {
  advanceUntilDecision,
  createTable,
  getBoardAscii,
  getSeed,
} from '@pokerpocket/engine'

const state = advanceUntilDecision(
  createTable(6, 20000, 100, { seed: 42 })
)

console.log(getBoardAscii(state))
console.log(getSeed(state))
โœ“ Typed selectors & actions
โœ“ Bring your own transport/UI
โœ“ Seed in, snapshot out

Interactive Playground

Drive the reducer, inspect hand evaluations, and feel the determinism of PokerPocket's engine.

Complete Hand Simulation

Click "Deal Hand" to simulate a complete Texas Hold'em hand with deterministic RNG.

Hand Evaluator

Add 5-7 cards to evaluate

Reducer Micro-Benchmark

Measure how many deterministic hands the reducer can process on your device.

Command Line Interface

The package ships with a zero-dependency CLI that wraps the same reducer powering the API.

Terminal
$ npx @pokerpocket/engine --seed 42
๐Ÿƒ PokerPocket CLI โ€” quick demo client for @pokerpocket/engine Number of players [2]: 3 Starting stack [1000]: 20000 Big blind size [50]: 100 Using RNG seed 42 === Phase: PREFLOP === -> [BTN] P1 | stack: 20000 | bet: 0 | hole: 5h 4d [SB] P2 | stack: 19950 | bet: 50 | hole: 3s 6d [BB] P3 | stack: 19900 | bet: 100 | hole: 9s 2h RNG: 926721163 P1's turn. Available: (f)old, (c)all 100, (r) raise to 200-20000, (q)uit Action: c

๐ŸŽฏ Deterministic runs

Seed, serialize, and resume reducer state at any point.

๐Ÿ”ง Dev tooling

Introspect players, board, pots, and RNG snapshots live.

๐Ÿ“ˆ Integration ready

Mirror the CLI flows when wiring bots, clients, or tests.

Integration Examples

Drop the reducer into different environments. Determinism makes tests and replay tooling effortless.

Pure reducer loop
import {
  advanceUntilDecision,
  call,
  check,
  createTable,
  getActionOptions,
  isHandDone,
  reduce,
} from '@pokerpocket/engine'

let state = advanceUntilDecision(createTable(3, 20000, 100))

while (!isHandDone(state)) {
  const options = getActionOptions(state)
  if (!options) break
  const action = options.canCheck ? check(options.seat) : call(options.seat)
  state = advanceUntilDecision(reduce(state, action))
}

console.log(state.tag) // "COMPLETE"
React hook
import {
  advanceUntilDecision,
  createTable,
  reduce,
} from '@pokerpocket/engine'

const usePoker = (players = 6) => {
  const [state, setState] = useState(() =>
    advanceUntilDecision(createTable(players, 20000, 100))
  )

  const dispatch = useCallback(action => {
    setState(prev => advanceUntilDecision(reduce(prev, action)))
  }, [])

  return { state, dispatch }
}
Node.js bot loop
import {
  advanceUntilDecision,
  check,
  createTable,
  getActionOptions,
  reduce,
} from '@pokerpocket/engine'

let state = advanceUntilDecision(createTable(3, 5000, 50, { seed: 9 }))
const options = getActionOptions(state)
if (options?.canCheck) {
  state = advanceUntilDecision(reduce(state, check(options.seat)))
}

console.log(state.tag)
Strongly typed actions
import { reduce } from '@pokerpocket/engine'
import type { Action, GameState } from '@pokerpocket/engine'

function apply(state: GameState, action: Action) {
  return reduce(state, action)
}

Quick Start

Install the engine, run the CLI, or embed the reducer in your stack.

CLI & library in two commands
npm install @pokerpocket/engine
npx @pokerpocket/engine --seed 42