poker-bitvaljs 1.1.2 → 1.2.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/bitval.js +0 -55
- package/package.json +1 -1
package/bitval.js
CHANGED
|
@@ -672,13 +672,6 @@ class BitVal {
|
|
|
672
672
|
// Generate valid matchups (always needed)
|
|
673
673
|
const validMatchups = this._generateValidMatchups(heroHands, villainHands, boardCards);
|
|
674
674
|
|
|
675
|
-
// Log all valid matchups for debugging
|
|
676
|
-
console.log(`\n[Valid Matchups] Generated ${validMatchups.length} valid matchups:`);
|
|
677
|
-
for (let i = 0; i < validMatchups.length; i++) {
|
|
678
|
-
const m = validMatchups[i];
|
|
679
|
-
console.log(` ${i + 1}. Hero: ${m.heroHand} vs Villain: ${m.villainHand}`);
|
|
680
|
-
}
|
|
681
|
-
|
|
682
675
|
// Calculate canonical mappings only if optimization is enabled
|
|
683
676
|
let hCanon = null;
|
|
684
677
|
let vCanon = null;
|
|
@@ -951,7 +944,6 @@ class BitVal {
|
|
|
951
944
|
// Group validMatchups by canonical key pair
|
|
952
945
|
// This ensures we only process matchups that actually exist, avoiding Cartesian product issues
|
|
953
946
|
const matchupGroups = new Map();
|
|
954
|
-
console.log(`\n[Sequential - Grouping Matchups] Processing ${setup.validMatchups.length} valid matchups:`);
|
|
955
947
|
for (const matchup of setup.validMatchups) {
|
|
956
948
|
const mHKey = this._getCanonicalKey(
|
|
957
949
|
matchup.heroHand,
|
|
@@ -967,8 +959,6 @@ class BitVal {
|
|
|
967
959
|
);
|
|
968
960
|
const key = `${mHKey}:${mVKey}`;
|
|
969
961
|
|
|
970
|
-
console.log(` Hero: ${matchup.heroHand} (${mHKey}) vs Villain: ${matchup.villainHand} (${mVKey}) -> Key: ${key}`);
|
|
971
|
-
|
|
972
962
|
if (!matchupGroups.has(key)) {
|
|
973
963
|
matchupGroups.set(key, {
|
|
974
964
|
heroKey: mHKey,
|
|
@@ -979,24 +969,16 @@ class BitVal {
|
|
|
979
969
|
}
|
|
980
970
|
matchupGroups.get(key).count++;
|
|
981
971
|
}
|
|
982
|
-
console.log(`\n[Sequential - Matchup Groups] Created ${matchupGroups.size} unique canonical key pairs:`);
|
|
983
|
-
for (const [key, group] of matchupGroups) {
|
|
984
|
-
console.log(` ${key}: ${group.count} matchup(s), example: ${group.representative.heroHand} vs ${group.representative.villainHand}`);
|
|
985
|
-
}
|
|
986
972
|
|
|
987
973
|
// Calculate accurate total matchups (number of unique canonical key pairs)
|
|
988
974
|
const totalMatchups = matchupGroups.size;
|
|
989
975
|
|
|
990
976
|
let matchupIndex = 0;
|
|
991
977
|
// Iterate over actual matchup groups (not Cartesian product)
|
|
992
|
-
console.log(`\n[Sequential - Evaluating Matchups] Starting evaluation of ${totalMatchups} unique matchups:`);
|
|
993
978
|
for (const [key, group] of matchupGroups) {
|
|
994
979
|
const validCount = group.count;
|
|
995
980
|
const validPair = group.representative;
|
|
996
981
|
|
|
997
|
-
// Log hand and canonical key mapping for debugging
|
|
998
|
-
console.log(`[Matchup] Hero: ${validPair.heroHand} (Key: ${group.heroKey}) vs Villain: ${validPair.villainHand} (Key: ${group.villainKey}) | Count: ${validCount}`);
|
|
999
|
-
|
|
1000
982
|
const cache = {
|
|
1001
983
|
heroKey: group.heroKey,
|
|
1002
984
|
heroHand: validPair.heroHand,
|
|
@@ -1015,12 +997,6 @@ class BitVal {
|
|
|
1015
997
|
totalMatchups
|
|
1016
998
|
);
|
|
1017
999
|
|
|
1018
|
-
// Log equity results for this matchup
|
|
1019
|
-
const totalIterations = matchupWin + matchupTie + matchupLose;
|
|
1020
|
-
const equity = totalIterations > 0 ? (matchupWin + matchupTie / 2) / totalIterations * 100 : 0;
|
|
1021
|
-
const weightedEquity = equity * validCount;
|
|
1022
|
-
console.log(`[Equity] ${validPair.heroHand} vs ${validPair.villainHand} (${validCount}x): Win=${matchupWin}, Tie=${matchupTie}, Lose=${matchupLose}, Total=${totalIterations}, Equity=${equity.toFixed(2)}%, Weighted=${weightedEquity.toFixed(2)}%`);
|
|
1023
|
-
|
|
1024
1000
|
win += matchupWin * validCount;
|
|
1025
1001
|
tie += matchupTie * validCount;
|
|
1026
1002
|
lose += matchupLose * validCount;
|
|
@@ -1077,7 +1053,6 @@ class BitVal {
|
|
|
1077
1053
|
// Group validMatchups by canonical key pair
|
|
1078
1054
|
// This ensures we only process matchups that actually exist, avoiding Cartesian product issues
|
|
1079
1055
|
const matchupGroups = new Map();
|
|
1080
|
-
console.log(`\n[Parallel - Grouping Matchups] Processing ${setup.validMatchups.length} valid matchups:`);
|
|
1081
1056
|
for (const matchup of setup.validMatchups) {
|
|
1082
1057
|
const mHKey = this._getCanonicalKey(
|
|
1083
1058
|
matchup.heroHand,
|
|
@@ -1093,8 +1068,6 @@ class BitVal {
|
|
|
1093
1068
|
);
|
|
1094
1069
|
const key = `${mHKey}:${mVKey}`;
|
|
1095
1070
|
|
|
1096
|
-
console.log(` Hero: ${matchup.heroHand} (${mHKey}) vs Villain: ${matchup.villainHand} (${mVKey}) -> Key: ${key}`);
|
|
1097
|
-
|
|
1098
1071
|
if (!matchupGroups.has(key)) {
|
|
1099
1072
|
matchupGroups.set(key, {
|
|
1100
1073
|
heroKey: mHKey,
|
|
@@ -1105,17 +1078,11 @@ class BitVal {
|
|
|
1105
1078
|
}
|
|
1106
1079
|
matchupGroups.get(key).count++;
|
|
1107
1080
|
}
|
|
1108
|
-
console.log(`\n[Parallel - Matchup Groups] Created ${matchupGroups.size} unique canonical key pairs:`);
|
|
1109
|
-
for (const [key, group] of matchupGroups) {
|
|
1110
|
-
console.log(` ${key}: ${group.count} matchup(s), example: ${group.representative.heroHand} vs ${group.representative.villainHand}`);
|
|
1111
|
-
}
|
|
1112
1081
|
|
|
1113
1082
|
// Collect all matchups to evaluate (only those that actually exist)
|
|
1114
1083
|
const matchupsToEvaluate = [];
|
|
1115
|
-
console.log(`\n[Parallel - Collecting Matchups] Building matchup list from ${matchupGroups.size} groups:`);
|
|
1116
1084
|
for (const [key, group] of matchupGroups) {
|
|
1117
1085
|
const validPair = group.representative;
|
|
1118
|
-
console.log(` Adding: ${key} (${group.count}x) - Hero: ${validPair.heroHand} vs Villain: ${validPair.villainHand}`);
|
|
1119
1086
|
matchupsToEvaluate.push({
|
|
1120
1087
|
key,
|
|
1121
1088
|
validCount: group.count,
|
|
@@ -1127,7 +1094,6 @@ class BitVal {
|
|
|
1127
1094
|
villainMask: validPair.villainMask
|
|
1128
1095
|
});
|
|
1129
1096
|
}
|
|
1130
|
-
console.log(`\n[Parallel - Matchups to Evaluate] Total: ${matchupsToEvaluate.length} unique matchups`);
|
|
1131
1097
|
|
|
1132
1098
|
// Calculate total matchups (number of unique canonical key pairs)
|
|
1133
1099
|
const totalMatchups = matchupsToEvaluate.length;
|
|
@@ -1208,18 +1174,6 @@ class BitVal {
|
|
|
1208
1174
|
|
|
1209
1175
|
for (const batchResults of allResults) {
|
|
1210
1176
|
for (const result of batchResults) {
|
|
1211
|
-
// Log equity results for this matchup
|
|
1212
|
-
const totalIterations = result.matchupWin + result.matchupTie + result.matchupLose;
|
|
1213
|
-
const equity = totalIterations > 0 ? (result.matchupWin + result.matchupTie / 2) / totalIterations * 100 : 0;
|
|
1214
|
-
const weightedEquity = equity * result.validCount;
|
|
1215
|
-
|
|
1216
|
-
// Find the matchup details from matchupsToEvaluate
|
|
1217
|
-
const matchup = matchupsToEvaluate.find(m => m.key === result.key);
|
|
1218
|
-
const heroHand = matchup ? matchup.heroHand : 'Unknown';
|
|
1219
|
-
const villainHand = matchup ? matchup.villainHand : 'Unknown';
|
|
1220
|
-
|
|
1221
|
-
console.log(`[Equity] ${heroHand} vs ${villainHand} (${result.validCount}x): Win=${result.matchupWin}, Tie=${result.matchupTie}, Lose=${result.matchupLose}, Total=${totalIterations}, Equity=${equity.toFixed(2)}%, Weighted=${weightedEquity.toFixed(2)}%`);
|
|
1222
|
-
|
|
1223
1177
|
win += result.matchupWin * result.validCount;
|
|
1224
1178
|
tie += result.matchupTie * result.validCount;
|
|
1225
1179
|
lose += result.matchupLose * result.validCount;
|
|
@@ -1357,21 +1311,12 @@ class BitVal {
|
|
|
1357
1311
|
const canonicalToHand = new Map();
|
|
1358
1312
|
const boardSuitCounts = boardCards.length > 0 ? this._getBoardSuitCounts(boardCards) : null;
|
|
1359
1313
|
|
|
1360
|
-
console.log(`\n[Canonical Mapping] Processing ${hands.length} hands:`);
|
|
1361
1314
|
for (const hand of hands) {
|
|
1362
1315
|
const key = this._getCanonicalKey(hand, boardCards, numberOfBoardCards, boardSuitCounts);
|
|
1363
1316
|
canonicalMap.set(key, (canonicalMap.get(key) || 0) + 1);
|
|
1364
1317
|
if (!canonicalToHand.has(key)) {
|
|
1365
1318
|
canonicalToHand.set(key, hand);
|
|
1366
1319
|
}
|
|
1367
|
-
console.log(` Hand: ${hand} -> Canonical Key: ${key}`);
|
|
1368
|
-
}
|
|
1369
|
-
|
|
1370
|
-
// Show summary of canonical key groupings
|
|
1371
|
-
console.log(`\n[Canonical Summary] ${canonicalMap.size} unique canonical keys from ${hands.length} hands:`);
|
|
1372
|
-
for (const [key, count] of canonicalMap.entries()) {
|
|
1373
|
-
const representativeHand = canonicalToHand.get(key);
|
|
1374
|
-
console.log(` ${key}: ${count} hand(s), example: ${representativeHand}`);
|
|
1375
1320
|
}
|
|
1376
1321
|
|
|
1377
1322
|
return { canonicalMap, canonicalToHand };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "poker-bitvaljs",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.2.0",
|
|
4
4
|
"description": "High-performance poker hand evaluator optimized for browser environments, using bitwise operations for rapid poker hand analysis and equity calculations.",
|
|
5
5
|
"main": "bitval.js",
|
|
6
6
|
"scripts": {
|