decideActionAsync
decideActionAsync(state: NativePokerState | PokerStateBytes, config: NativeBotConfig, opponentModel?: NativeOpponentModel | null, heroSeat?: number, options?: AsyncOptions): Promise<DecisionResult>
Import
const poker = require('poker-calculations');
ESM (Node):
import { createRequire } from 'module';
const require = createRequire(import.meta.url);
const poker = require('poker-calculations');
When to use
Bots and simulators that call decideAction often and must keep the JS thread responsive. Optional AsyncOptions cancel Monte Carlo inside decideAction via AbortSignal.
How to use
const poker = require('poker-calculations');
const d = await poker.decideActionAsync(state, { monteCarloSimulations: 2000 }, null, 0);
const ac = new AbortController();
const pending = poker.decideActionAsync(
state,
{ monteCarloSimulations: 50_000 },
null,
0,
{ signal: ac.signal },
);
// ac.abort(); // Promise rejects with AbortError