/**
* Poker game constants and configuration
*/
export const POSITIONS = {
IP: 'ip', // In position
OOP: 'oop' // Out of position
};
export const STREETS = {
PREFLOP: 'preflop',
FLOP: 'flop',
TURN: 'turn',
RIVER: 'river'
};
export const ACTIONS = {
BET: 'bet',
RAISE: 'raise',
DONK: 'donk',
ALLIN: 'allin',
CHECK: 'check',
CALL: 'call',
FOLD: 'fold'
};
export const POST_FLOP_STREETS = ['flop', 'turn', 'river'];
export const DEFAULT_SOLVER_CONFIG = {
thread_num: 8,
accuracy: 0.5,
max_iteration: 200,
print_interval: 10,
use_isomorphism: 1,
allin_threshold: 1.0,
dump_rounds: 2 // 0=flop, 1=turn, 2=river
};
export const CARD_RANKS = ['A', 'K', 'Q', 'J', 'T', '9', '8', '7', '6', '5', '4', '3', '2'];
export const CARD_SUITS = ['s', 'h', 'd', 'c'];
export const HAND_CATEGORIES = {
PAIRS: ['AA', 'KK', 'QQ', 'JJ', 'TT', '99', '88', '77', '66', '55', '44', '33', '22'],
BROADWAY: ['AK', 'AQ', 'AJ', 'KQ', 'KJ', 'QJ'],
HIGH_CARDS: ['AK', 'AQ', 'AJ', 'AT', 'KQ', 'KJ', 'KT', 'QJ', 'QT', 'JT']
};
/**
* Validate if a string represents valid card notation (rank + suit)
* @param {string} card - Card string (e.g., "As", "Kh", "2d")
* @returns {boolean}
*/
export function isValidCard(card) {
if (!card || card.length !== 2) return false;
const rank = card[0];
const suit = card[1].toLowerCase();
return CARD_RANKS.includes(rank) && CARD_SUITS.includes(suit);
}
/**
* Validate board string format (comma-separated cards)
* @param {string} board - Board string (e.g., "As,Kh,Qd")
* @returns {boolean}
*/
export function isValidBoard(board) {
if (!board || board.trim() === '') {
return true; // Empty board is valid (preflop)
}
const cards = board.split(',').map(c => c.trim());
// Check for valid number of cards (1-5 for flop/turn/river)
if (cards.length < 1 || cards.length > 5) return false;
return cards.every(isValidCard);
}
/**
* Get street name from number of board cards
* @param {number} numCards - Number of cards on board
* @returns {string}
*/
export function getStreetName(numCards) {
switch (numCards) {
case 0:
return STREETS.PREFLOP;
case 3:
return STREETS.FLOP;
case 4:
return STREETS.TURN;
case 5:
return STREETS.RIVER;
default:
throw new Error(`Invalid number of board cards: ${numCards}`);
}
}
export default {
POSITIONS,
STREETS,
ACTIONS,
POST_FLOP_STREETS,
DEFAULT_SOLVER_CONFIG,
CARD_RANKS,
CARD_SUITS,
isValidCard,
isValidBoard,
getStreetName
};