PokerAIの計算済みデータとリアルタイムソルバーで作る低遅延のポーカー分析
PokerAIからフロップの計算済み戦略を取得し、アクション頻度をすぐに表示します。200NLの実際の3ベットハンドを使い、局面の検索、アクションとボードの切り替え、両者のレンジを引き継いだターンとリバーのリアルタイム計算までを紹介します。
/flop/tree と /flop/node で現在のノードの戦略を取得します。レスポンスが届いたらアクション頻度を表示します。ユーザーが次のカードを選んだら、アクションの経路に沿って両者のレンジを更新し、そのストリートの計算を送信します。計算中も前の戦略を表示できます。計算済みデータとリアルタイムソルバーを組み合わせる場面
Cacheの一覧に対象ハンドがない場合や、ターン以降のレンジやベットサイズを自分で選ぶ場合は、計算済みのフロップ戦略から始め、後続のストリートを個別に計算します。この手順は Free、Starter、Builder、Pro で利用でき、各プランの計算済み戦略クォータとソルバークォータを使います。取得可能なフロップの計算済み局面が必要です。
実際のアクションに沿って両者のレンジを更新し、そのレンジでターンとリバーを別々に計算します。結果は3ストリート全体のツリーのナッシュ均衡をストリートごとに近似したものです。後続の戦略は入力レンジ、スタック、利用可能なサイズ、計算結果に依存します。まずフロップを表示し、後続の戦略は計算が完了した順に表示します。
200NLの3ベットハンドの基本情報
プリフロップパックは 6max_RC_100bb_200NL です。MP(ミドルポジション)がオープンし、SB(スモールブラインド)が3ベットします。SBのハンドは A♥K♥、フロップは 4♣8♦9♥ です。フロップ開始時のポットは19 BB、有効スタックは91 BBです。
| ストリートとボード | アクション | 次の段階 |
|---|---|---|
| Flop4♣ 8♦ 9♥ | SBが13 BBをベット MPがコール | A♠が出る |
| TurnA♠ | SBが14 BBをベット MPがコール | 7♦が出る |
| River7♦ | SBが22 BBをベット MPがコール | ショーダウン |
SBは3ストリートで13、14、22 BBをベットし、MPは毎回コールします。Cache APIガイドと同じハンドです。リアルタイムソルバーの例ではSBをOOP、MPをIPとして扱います。
取得可能な局面を探す
/availability にプリフロップパック、フロップ、局面を送り、計算済みライブラリから取得できるか確認します。有効なAPIキーがあれば無料で確認できます。
curl 'https://pokerai.bet/v1/gto/availability' \
-H "Authorization: Bearer $POKERAI_API_KEY" \
-H 'Content-Type: application/json' \
-d '{"type":"flop","request":{"preflop_pack":"6max_RC_100bb_200NL","board":"4c8d9h","pot_type":"3BET","positions":{"raiser":"MP","three_bettor":"SB","hero":"SB"}}}'
進む前に status: "available"、match: "exact"、resolved_preflop_pack を確認します。既存のフロップエンドポイントでは、指定パックに局面がないと既定パックにフォールバックすることがあります。同じハンドを再現するには、データソースの切り替え前に解決されたパックを確認してください。
フロップ戦略を取得する
APIキーはバックエンドで管理し、そこから /flop/tree を呼び出します。ルートノードのトークンを取得したら、/flop/node に hole_cards: "AhKh" とともに送り、A♥K♥の戦略を取得します。
- 1. 取得可能な局面を探す
/availability計算済みの局面を無料で確認 - 2. 戦略を取得して表示
/flop/treeと/flop/nodeツリーの取得は計算済み戦略1回分。ノードの取得は無料。 - 3. レンジを更新して計算
/flop/projected-range、/turn/projected-rangeと/solverターンとリバーを別々に送信
次のリクエストではフロップのルートを読み取り、計算済み戦略クォータを1回消費します。post や waitForTree は完全なコード例にあります。
const spot = {
preflop_pack: "6max_RC_100bb_200NL",
board: "4c8d9h",
pot_type: "3BET",
positions: { hero: "SB", raiser: "MP", three_bettor: "SB" },
};
const hand = "AhKh";
const available = await post("/availability", { type: "flop", request: spot });
if (available.status !== "available" || available.match !== "exact" ||
available.resolved_preflop_pack !== spot.preflop_pack) {
throw new Error("This exact presolved Flop spot is not available.");
}
const flop = await post("/flop/tree", { ...spot, hole_cards: hand });
const root = flop.nodes.find((entry) => entry.node === "root" && entry.is_hero);
if (!root?.token) throw new Error("The expected SB root is unavailable.");
const flopStrategy = await post("/flop/node", {
node: root.token,
hole_cards: hand,
});
strategy をアクション頻度として表示し、後続の読み取りのためにツリーのノードトークンを保持します。レスポンスの node: "root" は経路ラベルに使えます。追加のリクエストでは node に対象のトークンを渡します。
レンジ全体の戦略行列があれば、ハンドを切り替えるときは対応する行を選びます。アクションノードが変わったら、戦略を再度取得します。
アクションに沿ってターンとリバーへ進む
フロップでSBが13 BBをベットし、MPがコールします。ターンはA♠です。SBが14 BBをベットし、MPが再びコールすると、リバーに7♦が出ます。レンジの更新には各ストリートの最後のコールも含め、相手がどのハンドでコールするかを反映します。
| ストリートとボード | 開始時のポット | 有効スタック |
|---|---|---|
| Flop4♣ 8♦ 9♥ | 19 BB | 91 BB |
| TurnA♠ | 45 BB | 78 BB |
| River7♦ | 73 BB | 64 BB |
フロップのコール後に両者のレンジを更新する
/flop/node でベット後の相手ノードにコールがあることを確認します。元の局面と末尾が /CALL の経路を /flop/projected-range に渡します。このエンドポイントは計算済みツリーから有効レンジを読み、アクション後に残るレンジを求めます。
const action = flopStrategy.strategy.find((row) => row.action === "bet" &&
!row.allin && row.amount_bb === 13);
const afterBet = flop.nodes.find((entry) => entry.node === "root/BET_13" &&
!entry.is_hero);
if (!action || !afterBet?.token) throw new Error("The 13 BB Flop branch is unavailable.");
const opponent = await post("/flop/node", { node: afterBet.token });
if (!opponent.actions?.some((row) => row.action === "call")) {
throw new Error("The Flop call branch is unavailable.");
}
const turnRanges = await post("/flop/projected-range", {
...spot,
node_id: afterBet.node + "/CALL",
normalize: false,
bluff_discount_ratio: 1,
});
range_oop_new_raw と range_ip_new_raw から重み付きコンボを取得します。レンジは前のストリートのボードを基に更新されます。計算を送信する前に新しいボードと衝突するコンボを除き、残りのコンボと重みを維持します。この例の AhKh は表示用で、レンジの更新と計算には両者のレンジ全体を使います。/v1/gto/range を直接呼び出してツリーを構築する場合は、フロップツリーの ranges.effective を起点にします。
A♠が出たらターンを計算する
/solver に4枚のボード 4c8d9hAs、A♠を含むコンボを除いた両者のレンジ、ポットと有効スタックを渡します。公開のサイズ指定はポットに対する整数パーセントです。実測では45 BBのポットで 31 が14 BBのベットを生成しました。以後は実際に返ったサイズを使います。
if (!turnRanges.range_oop_new_raw || !turnRanges.range_ip_new_raw) {
throw new Error("Turn ranges are unavailable.");
}
const turnBoard = ["4c", "8d", "9h", "As"];
const turn = await post("/solver", {
board: turnBoard.join(""),
oop_range: rangeForBoard(turnRanges.range_oop_new_raw, turnBoard),
ip_range: rangeForBoard(turnRanges.range_ip_new_raw, turnBoard),
pot: flop.pot + 2 * action.amount_bb,
effective_stack: flop.effective_stack - action.amount_bb,
hero: "OOP",
bet_sizes: { turn: [31] },
donk_sizes: { turn: [31] },
});
const turnTree = await waitForTree(turn.solve);
const turnRoot = turnTree.nodes.find((entry) => entry.node === "root" && entry.is_hero);
if (!turnRoot?.token) throw new Error("The expected Turn root is unavailable.");
const turnStrategy = await post("/solver/node", {
node: turnRoot.token,
hole_cards: hand,
});
if (!Array.isArray(turnStrategy.strategy)) throw new Error("Turn strategy is unavailable.");
ターンのコール後にリバーを計算する
ターンの計算ハンドルと対応するアクションの経路を /turn/projected-range に渡します。リアルタイム計算のツリーは root/BET 14.000000 のような経路を返します。実際に返った経路に /CALL を付けます。両者のレンジから7♦を含むコンボを除き、4c8d9hAs7d で新しく計算を送信します。
const selected = await selectBetCall(turnTree, turnStrategy, 14);
const riverRanges = await post("/turn/projected-range", {
solve: turn.solve,
node_id: selected.entry.node + "/CALL",
normalize: false,
bluff_discount_ratio: 1,
});
if (!riverRanges.range_oop_new_raw || !riverRanges.range_ip_new_raw) {
throw new Error("River ranges are not ready.");
}
const riverBoard = [...turnBoard, "7d"];
const river = await post("/solver", {
board: riverBoard.join(""),
oop_range: rangeForBoard(riverRanges.range_oop_new_raw, riverBoard),
ip_range: rangeForBoard(riverRanges.range_ip_new_raw, riverBoard),
pot: Number((turnTree.pot + 2 * selected.bb).toFixed(2)),
effective_stack: Number((turnTree.effective_stack - selected.bb).toFixed(2)),
hero: "OOP",
bet_sizes: { river: [30] },
donk_sizes: { river: [30] },
});
const riverTree = await waitForTree(river.solve);
const riverRoot = riverTree.nodes.find((entry) => entry.node === "root" && entry.is_hero);
if (!riverRoot?.token) throw new Error("The expected River root is unavailable.");
const riverStrategy = await post("/solver/node", {
node: riverRoot.token,
hole_cards: hand,
});
if (!Array.isArray(riverStrategy.strategy)) throw new Error("River strategy is unavailable.");
const showDown = await selectBetCall(riverTree, riverStrategy, 22);
console.log({ turn: selected.bb, river: showDown.bb });
元のリバーベットは22 BBです。実測では例のサイズ指定でその分岐が返りました。ソルバーが返す実際の額と頻度を表示してください。コールでショーダウンに進み、最後の読み取りが終わったら /solver/release でリソースを解放できます。
計算中も戦略を表示する
戦略と計算状況を一緒に表示します。ターンやリバーを選択したら、新しいストリートの計算中も前の戦略を維持します。元の計算ハンドルで /solver/tree をポーリングし、spot_status: "queryable" になったら返ったノードトークンで /solver/node を呼び出します。
429 busy が返ったら、再試行するタイミングはユーザーが選びます。no_nodes、error、expired では待機を終了します。送信がタイムアウトして結果が不明なら、画面を維持してクォータを消費する二重送信を防ぎます。アクションやボードが変わったら、リクエストの文脈を基に前の選択への遅延レスポンスを無視します。
リクエスト時間とクォータ
フロップの0.077479秒は計算済みツリーとノードの取得を含みます。ターンの2.258036秒は修正後の計算送信から測定しました。先に行ったフロップのレンジ更新は別計測で0.079021秒でした。リバーの2.190538秒はターンのレンジ更新から始まり、送信、ポーリング、ノード取得までを含みます。Cacheの棒は同じハンドの個別の戦略リクエストです。
| 取得経路 | 所要時間 | 計測回 | |
|---|---|---|---|
| Flop4♣ 8♦ 9♥ | |||
| Cacheの戦略 | 4.425秒 | A | |
| 既存エンドポイント | 0.077秒 | D | |
| TurnA♠ | |||
| Cacheの戦略 | 1.348秒 | B | |
| 既存エンドポイント | 2.258秒 | E | |
| River7♦ | |||
| Cacheの戦略 | 1.319秒 | C | |
| 既存エンドポイント | 2.191秒 | E | |
| API操作 | 消費クォータ |
|---|---|
/availability で局面を確認 |
0 |
/flop/tree で計算済みツリーを取得 |
計算済み戦略1回 |
| 有効なトークンで通常のフロップ/ソルバーノードを取得 | 0 |
/flop/projected-range でフロップの両レンジを更新 |
計算済み戦略1回 |
/solver でターンまたはリバーの新しい計算を開始 |
新規計算ごとにソルバー1回 |
/solver/tree のポーリング、ターンレンジの更新、計算の解放 |
0 |
例の3ストリートをたどると計算済み戦略クォータを2回、ソルバークォータを最大2回使います。 一致する計算結果がそのまま返ったら、実際の消費は solve_quota で確認してください。通常のノード取得やポーリングは元のトークンまたはハンドルを再利用します。
完全な接続例を実行する
ポジション、ホールカード、ボード、アクションの経路を一緒に保持します。フロップの戦略が届いたら表示し、ターンとリバーの読み込みとエラーは個別に扱います。ボード、レンジ、ポット、有効スタック、サイズが同じなら、処理中の送信を再利用します。
以下の補助関数を先ほどの4つのJavaScriptブロックより前に置き、Node.jsのESモジュールとして実行します。本番APIを呼び出すとアカウントのクォータを消費します。
const API = "https://pokerai.bet/v1/gto";
const key = process.env.POKERAI_API_KEY;
if (!key) throw new Error("Set POKERAI_API_KEY on your backend.");
async function post(path, body, timeoutMs = 15_000) {
const response = await fetch(API + path, {
method: "POST",
headers: { Authorization: `Bearer ${key}`, "Content-Type": "application/json" },
body: JSON.stringify(body),
signal: AbortSignal.timeout(timeoutMs),
});
const payload = await response.json();
if (!response.ok) throw new Error(`${path}: HTTP ${response.status} (${payload.error ?? payload.status ?? "unknown"})`);
return payload;
}
function rangeForBoard(range, board) {
const blocked = new Set(board);
const combos = range.split(",").map((item) => item.trim()).filter((item) => {
const match = /^([2-9TJQKA][cdhs])([2-9TJQKA][cdhs]):([0-9.]+(?:e[+-]?\d+)?)$/i.exec(item);
if (!match || !Number.isFinite(Number(match[3]))) {
throw new Error("Invalid weighted combo in the projected range.");
}
const canonical = (card) => card[0].toUpperCase() + card[1].toLowerCase();
const first = canonical(match[1]);
const second = canonical(match[2]);
if (first === second) throw new Error("Duplicate card in a projected combo.");
return !blocked.has(first) && !blocked.has(second);
});
if (!combos.length) throw new Error("No legal combinations for the next board.");
return combos.join(",");
}
async function selectBetCall(tree, strategy, targetBb) {
const bets = tree.nodes.flatMap((entry) => {
const match = /^root\/BET (\d+(?:\.\d+)?)$/.exec(entry.node);
return match && !entry.is_hero && entry.token ? [{ entry, bb: Number(match[1]) }] : [];
});
const selected = bets.sort((a, b) => Math.abs(a.bb - targetBb) - Math.abs(b.bb - targetBb))[0];
if (!selected || Math.abs(selected.bb - targetBb) > 0.5 ||
!strategy.strategy.some((row) => row.action === "bet" && !row.allin &&
Math.abs(row.amount_bb - selected.bb) < 0.02)) {
throw new Error(`No supported bet sizing close to ${targetBb} BB.`);
}
const opponent = await post("/solver/node", { node: selected.entry.token });
if (!opponent.actions?.some((row) => row.action === "call")) {
throw new Error("The call branch is unavailable.");
}
return selected;
}
async function waitForTree(solve, deadlineMs = 90_000) {
if (typeof solve !== "string" || !solve) throw new Error("Missing solve handle.");
const deadline = Date.now() + deadlineMs;
while (Date.now() < deadline) {
const tree = await post("/solver/tree", { solve }, Math.min(10_000, deadline - Date.now()));
if (tree.spot_status === "queryable") return tree;
if (!["available", "computing"].includes(tree.spot_status)) {
throw new Error(`Solve stopped: ${tree.spot_status ?? "missing status"}`);
}
const delay = Math.min(1_000, deadline - Date.now());
if (delay > 0) await new Promise((resolve) => setTimeout(resolve, delay));
}
throw new Error("Solve polling timed out. Keep the original handle.");
}
実測データと再現
ハンドとアクション経路は 2026年11月18日 の Cache API本番計測 に基づきます。11月19日 に公開HTTPSで既存エンドポイントを測定し、同じパック、ハンドと13、14、22 BBの3回のベットとコールを確認しました。ソルバーは2回とも新規計算を開始しました。計算済み戦略クォータを2回、ソルバークォータを2回消費しました。
最初のターン送信は invalid_range となり、ソルバークォータを消費しませんでした。前のストリートのレンジにA♠が残っていたためです。例のとおり新しいボードと衝突するコンボを除くと、元の経路で計算できました。図は収集回を分けて記載しています。レンジ更新とフィルタリングの前後で公開ボードとアクション条件は同じです。
引用時は戦略パック、ボード、アクション経路、日付、計測方法を記載してください。このガイドはトレーニング、研究、セッション後のレビュー向けです。ここでのリアルタイム分析とはツールで対話的に局面を探索することです。リアルマネーテーブルでのリアルタイム支援は禁止されています。
APIドキュメント · APIリファレンス · リアルタイムソルバーの手順 · OpenAPI · llms.txt
全体がキャッシュ済みなら3ストリートの戦略を直接取得する
BuilderまたはProで局面全体がキャッシュ済みなら、アクションやボードを変更しながら同じ計算済みツリーの戦略を取得できます。関連ガイドでは同じ200NLの3ベットハンドを使い、無料のカバレッジ確認から3ストリートの戦略、必要に応じたEVとエクイティの取得まで紹介します。PokerAI Cache APIで作る低遅延のリアルタイムポーカー分析ツール