@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.js
CHANGED
|
@@ -56774,6 +56774,41 @@ class PokerSolver {
|
|
|
56774
56774
|
}
|
|
56775
56775
|
return bestHand;
|
|
56776
56776
|
}
|
|
56777
|
+
/**
|
|
56778
|
+
* Find the best Omaha hand: EXACTLY 2 of the 4 hole cards and EXACTLY 3 of
|
|
56779
|
+
* the 5 board cards — C(4,2) x C(5,3) = 60 candidates, ranked like Hold'em.
|
|
56780
|
+
* Mirrors the engine's FindBestOmahaHand (poker-vm#2650).
|
|
56781
|
+
*/
|
|
56782
|
+
static findBestOmahaHand(holeCards, communityCards) {
|
|
56783
|
+
if (holeCards.length !== 4) {
|
|
56784
|
+
throw new Error("Omaha requires exactly 4 hole cards");
|
|
56785
|
+
}
|
|
56786
|
+
if (communityCards.length !== 5) {
|
|
56787
|
+
throw new Error("Omaha requires exactly 5 community cards");
|
|
56788
|
+
}
|
|
56789
|
+
let bestHand = null;
|
|
56790
|
+
for (const pair of this.getCombinationsFlexible(holeCards, 2)) {
|
|
56791
|
+
for (const triple of this.getCombinationsFlexible(communityCards, 3)) {
|
|
56792
|
+
const evaluation = this.evaluateHand([...pair, ...triple]);
|
|
56793
|
+
if (!bestHand || this.compareHands(evaluation, bestHand) > 0) {
|
|
56794
|
+
bestHand = evaluation;
|
|
56795
|
+
}
|
|
56796
|
+
}
|
|
56797
|
+
}
|
|
56798
|
+
if (!bestHand) {
|
|
56799
|
+
throw new Error("Failed to evaluate hand");
|
|
56800
|
+
}
|
|
56801
|
+
return bestHand;
|
|
56802
|
+
}
|
|
56803
|
+
/**
|
|
56804
|
+
* Best hand for a variant from hole cards and a full 5-card board.
|
|
56805
|
+
*/
|
|
56806
|
+
static bestHandForVariant(variant, holeCards, communityCards) {
|
|
56807
|
+
if (variant === exports.GameVariant.OMAHA) {
|
|
56808
|
+
return this.findBestOmahaHand(holeCards, communityCards);
|
|
56809
|
+
}
|
|
56810
|
+
return this.findBestHand([...holeCards, ...communityCards]);
|
|
56811
|
+
}
|
|
56777
56812
|
/**
|
|
56778
56813
|
* Evaluate a hand with any number of cards (2-7)
|
|
56779
56814
|
* This is useful for showing hand strength during all betting rounds
|
|
@@ -57168,12 +57203,14 @@ class PokerSolver {
|
|
|
57168
57203
|
}
|
|
57169
57204
|
/**
|
|
57170
57205
|
* Calculate win percentages for multiple players (2+) using Monte Carlo simulation
|
|
57171
|
-
* @param hands Array of hole cards for each player (each
|
|
57206
|
+
* @param hands Array of hole cards for each player (2 each for Hold'em, 4 for Omaha)
|
|
57172
57207
|
* @param communityCards Current community cards (0-5 cards)
|
|
57173
57208
|
* @param simulations Number of simulations to run (default: 10000)
|
|
57209
|
+
* @param variant The table's variant; omitted = Texas Hold'em. Omaha hands are
|
|
57210
|
+
* scored with the two-plus-three rule (ui#769).
|
|
57174
57211
|
* @returns Object containing win percentages for each player and overall tie percentage
|
|
57175
57212
|
*/
|
|
57176
|
-
static calculateMultiPlayerEquity(hands, communityCards = [], simulations = 10000) {
|
|
57213
|
+
static calculateMultiPlayerEquity(hands, communityCards = [], simulations = 10000, variant) {
|
|
57177
57214
|
// Validate inputs
|
|
57178
57215
|
if (hands.length < 2) {
|
|
57179
57216
|
throw new Error("Need at least 2 hands to calculate equity");
|
|
@@ -57181,9 +57218,10 @@ class PokerSolver {
|
|
|
57181
57218
|
if (hands.length > 10) {
|
|
57182
57219
|
throw new Error("Maximum 10 hands supported");
|
|
57183
57220
|
}
|
|
57221
|
+
const holeCount = holeCardsPerPlayer(variant);
|
|
57184
57222
|
for (let i = 0; i < hands.length; i++) {
|
|
57185
|
-
if (hands[i].length !==
|
|
57186
|
-
throw new Error(`Hand ${i} must have exactly
|
|
57223
|
+
if (hands[i].length !== holeCount) {
|
|
57224
|
+
throw new Error(`Hand ${i} must have exactly ${holeCount} cards`);
|
|
57187
57225
|
}
|
|
57188
57226
|
}
|
|
57189
57227
|
if (communityCards.length > 5) {
|
|
@@ -57210,10 +57248,7 @@ class PokerSolver {
|
|
|
57210
57248
|
// Deal remaining community cards
|
|
57211
57249
|
const fullCommunityCards = [...communityCards, ...shuffledDeck.slice(0, cardsNeeded)];
|
|
57212
57250
|
// Evaluate all hands
|
|
57213
|
-
const evaluations = hands.map(hand =>
|
|
57214
|
-
const fullHand = [...hand, ...fullCommunityCards];
|
|
57215
|
-
return this.findBestHand(fullHand);
|
|
57216
|
-
});
|
|
57251
|
+
const evaluations = hands.map(hand => this.bestHandForVariant(variant, hand, fullCommunityCards));
|
|
57217
57252
|
// Find winners using existing findWinners method
|
|
57218
57253
|
const winnerIndices = this.findWinners(evaluations);
|
|
57219
57254
|
// Update win counters
|