@block52/poker-vm-sdk 1.6.0 → 1.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.ts +14 -2
- package/dist/index.esm.js +43 -8
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +43 -8
- package/dist/index.js.map +1 -1
- package/dist/pokerSolver.d.ts +15 -3
- package/dist/pokerSolver.d.ts.map +1 -1
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -46073,6 +46073,16 @@ declare class PokerSolver {
|
|
|
46073
46073
|
* Find the best 5-card hand from 7 cards
|
|
46074
46074
|
*/
|
|
46075
46075
|
static findBestHand(cards: Card[]): HandEvaluation;
|
|
46076
|
+
/**
|
|
46077
|
+
* Find the best Omaha hand: EXACTLY 2 of the 4 hole cards and EXACTLY 3 of
|
|
46078
|
+
* the 5 board cards — C(4,2) x C(5,3) = 60 candidates, ranked like Hold'em.
|
|
46079
|
+
* Mirrors the engine's FindBestOmahaHand (poker-vm#2650).
|
|
46080
|
+
*/
|
|
46081
|
+
static findBestOmahaHand(holeCards: Card[], communityCards: Card[]): HandEvaluation;
|
|
46082
|
+
/**
|
|
46083
|
+
* Best hand for a variant from hole cards and a full 5-card board.
|
|
46084
|
+
*/
|
|
46085
|
+
private static bestHandForVariant;
|
|
46076
46086
|
/**
|
|
46077
46087
|
* Evaluate a hand with any number of cards (2-7)
|
|
46078
46088
|
* This is useful for showing hand strength during all betting rounds
|
|
@@ -46154,12 +46164,14 @@ declare class PokerSolver {
|
|
|
46154
46164
|
static calculateWinPercentages(handA: Card[], handB: Card[], communityCards?: Card[], simulations?: number): [number, number, number];
|
|
46155
46165
|
/**
|
|
46156
46166
|
* Calculate win percentages for multiple players (2+) using Monte Carlo simulation
|
|
46157
|
-
* @param hands Array of hole cards for each player (each
|
|
46167
|
+
* @param hands Array of hole cards for each player (2 each for Hold'em, 4 for Omaha)
|
|
46158
46168
|
* @param communityCards Current community cards (0-5 cards)
|
|
46159
46169
|
* @param simulations Number of simulations to run (default: 10000)
|
|
46170
|
+
* @param variant The table's variant; omitted = Texas Hold'em. Omaha hands are
|
|
46171
|
+
* scored with the two-plus-three rule (ui#769).
|
|
46160
46172
|
* @returns Object containing win percentages for each player and overall tie percentage
|
|
46161
46173
|
*/
|
|
46162
|
-
static calculateMultiPlayerEquity(hands: Card[][], communityCards?: Card[], simulations?: number): {
|
|
46174
|
+
static calculateMultiPlayerEquity(hands: Card[][], communityCards?: Card[], simulations?: number, variant?: GameVariant): {
|
|
46163
46175
|
winPercentages: number[];
|
|
46164
46176
|
tiePercentage: number;
|
|
46165
46177
|
};
|
package/dist/index.esm.js
CHANGED
|
@@ -56772,6 +56772,41 @@ class PokerSolver {
|
|
|
56772
56772
|
}
|
|
56773
56773
|
return bestHand;
|
|
56774
56774
|
}
|
|
56775
|
+
/**
|
|
56776
|
+
* Find the best Omaha hand: EXACTLY 2 of the 4 hole cards and EXACTLY 3 of
|
|
56777
|
+
* the 5 board cards — C(4,2) x C(5,3) = 60 candidates, ranked like Hold'em.
|
|
56778
|
+
* Mirrors the engine's FindBestOmahaHand (poker-vm#2650).
|
|
56779
|
+
*/
|
|
56780
|
+
static findBestOmahaHand(holeCards, communityCards) {
|
|
56781
|
+
if (holeCards.length !== 4) {
|
|
56782
|
+
throw new Error("Omaha requires exactly 4 hole cards");
|
|
56783
|
+
}
|
|
56784
|
+
if (communityCards.length !== 5) {
|
|
56785
|
+
throw new Error("Omaha requires exactly 5 community cards");
|
|
56786
|
+
}
|
|
56787
|
+
let bestHand = null;
|
|
56788
|
+
for (const pair of this.getCombinationsFlexible(holeCards, 2)) {
|
|
56789
|
+
for (const triple of this.getCombinationsFlexible(communityCards, 3)) {
|
|
56790
|
+
const evaluation = this.evaluateHand([...pair, ...triple]);
|
|
56791
|
+
if (!bestHand || this.compareHands(evaluation, bestHand) > 0) {
|
|
56792
|
+
bestHand = evaluation;
|
|
56793
|
+
}
|
|
56794
|
+
}
|
|
56795
|
+
}
|
|
56796
|
+
if (!bestHand) {
|
|
56797
|
+
throw new Error("Failed to evaluate hand");
|
|
56798
|
+
}
|
|
56799
|
+
return bestHand;
|
|
56800
|
+
}
|
|
56801
|
+
/**
|
|
56802
|
+
* Best hand for a variant from hole cards and a full 5-card board.
|
|
56803
|
+
*/
|
|
56804
|
+
static bestHandForVariant(variant, holeCards, communityCards) {
|
|
56805
|
+
if (variant === GameVariant.OMAHA) {
|
|
56806
|
+
return this.findBestOmahaHand(holeCards, communityCards);
|
|
56807
|
+
}
|
|
56808
|
+
return this.findBestHand([...holeCards, ...communityCards]);
|
|
56809
|
+
}
|
|
56775
56810
|
/**
|
|
56776
56811
|
* Evaluate a hand with any number of cards (2-7)
|
|
56777
56812
|
* This is useful for showing hand strength during all betting rounds
|
|
@@ -57166,12 +57201,14 @@ class PokerSolver {
|
|
|
57166
57201
|
}
|
|
57167
57202
|
/**
|
|
57168
57203
|
* Calculate win percentages for multiple players (2+) using Monte Carlo simulation
|
|
57169
|
-
* @param hands Array of hole cards for each player (each
|
|
57204
|
+
* @param hands Array of hole cards for each player (2 each for Hold'em, 4 for Omaha)
|
|
57170
57205
|
* @param communityCards Current community cards (0-5 cards)
|
|
57171
57206
|
* @param simulations Number of simulations to run (default: 10000)
|
|
57207
|
+
* @param variant The table's variant; omitted = Texas Hold'em. Omaha hands are
|
|
57208
|
+
* scored with the two-plus-three rule (ui#769).
|
|
57172
57209
|
* @returns Object containing win percentages for each player and overall tie percentage
|
|
57173
57210
|
*/
|
|
57174
|
-
static calculateMultiPlayerEquity(hands, communityCards = [], simulations = 10000) {
|
|
57211
|
+
static calculateMultiPlayerEquity(hands, communityCards = [], simulations = 10000, variant) {
|
|
57175
57212
|
// Validate inputs
|
|
57176
57213
|
if (hands.length < 2) {
|
|
57177
57214
|
throw new Error("Need at least 2 hands to calculate equity");
|
|
@@ -57179,9 +57216,10 @@ class PokerSolver {
|
|
|
57179
57216
|
if (hands.length > 10) {
|
|
57180
57217
|
throw new Error("Maximum 10 hands supported");
|
|
57181
57218
|
}
|
|
57219
|
+
const holeCount = holeCardsPerPlayer(variant);
|
|
57182
57220
|
for (let i = 0; i < hands.length; i++) {
|
|
57183
|
-
if (hands[i].length !==
|
|
57184
|
-
throw new Error(`Hand ${i} must have exactly
|
|
57221
|
+
if (hands[i].length !== holeCount) {
|
|
57222
|
+
throw new Error(`Hand ${i} must have exactly ${holeCount} cards`);
|
|
57185
57223
|
}
|
|
57186
57224
|
}
|
|
57187
57225
|
if (communityCards.length > 5) {
|
|
@@ -57208,10 +57246,7 @@ class PokerSolver {
|
|
|
57208
57246
|
// Deal remaining community cards
|
|
57209
57247
|
const fullCommunityCards = [...communityCards, ...shuffledDeck.slice(0, cardsNeeded)];
|
|
57210
57248
|
// Evaluate all hands
|
|
57211
|
-
const evaluations = hands.map(hand =>
|
|
57212
|
-
const fullHand = [...hand, ...fullCommunityCards];
|
|
57213
|
-
return this.findBestHand(fullHand);
|
|
57214
|
-
});
|
|
57249
|
+
const evaluations = hands.map(hand => this.bestHandForVariant(variant, hand, fullCommunityCards));
|
|
57215
57250
|
// Find winners using existing findWinners method
|
|
57216
57251
|
const winnerIndices = this.findWinners(evaluations);
|
|
57217
57252
|
// Update win counters
|