evaluateCardCodes

Evaluates the 5 - 7 card codes to arrive at a number representing the hand strength, smaller is better.

evaluateCardCodes(cards: Array<Number>): Number
Parameters
cards (Array<Number>) the cards, i.e. [ 49, 36, 4, 48, 41 ]
Returns
Number: the strength of the hand comprised by the card codes

evaluateCards

Evaluates the 5 - 7 cards to arrive at a number representing the hand strength, smaller is better.

evaluateCards(cards: Array<String>): Number
Parameters
cards (Array<String>) the cards, i.e. [ 'Ah', 'Ks', 'Td', '3c', 'Ad' ]
Returns
Number: the strength of the hand comprised by the cards

evaluateCardsFast

Same as evaluateCards but skips cards argument type check to be more performant.

evaluateCardsFast(cards: any)
Parameters
cards (any)

evaluateBoard

Evaluates the given board of 5 to 7 cards provided as part of the board to arrive at a number representing the hand strength, smaller is better.

evaluateBoard(board: String): Number
Parameters
board (String) the board, i.e. 'Ah Ks Td 3c Ad'
Returns
Number: the strength of the hand comprised by the cards of the board

rankCards

Evaluates the 5 - 7 cards and then calculates the hand rank.

rankCards(cards: Array<String>): Number
Parameters
cards (Array<String>) the cards, i.e. [ 'Ah', 'Ks', 'Td', '3c', 'Ad' ]
Returns
Number: the rank of the hand comprised by the cards, i.e. 1 for FOUR_OF_A_KIND (enumerated in ranks)

rankCardsFast

Same as rankCards but skips cards argument type check to be more performant.

rankCardsFast(cards: any)
Parameters
cards (any)

rankCardCodes

Evaluates the 5 - 7 card codes and then calculates the hand rank.

rankCardCodes(cardCodes: Array<Number>): Number
Parameters
cardCodes (Array<Number>) the card codes whose ranking to determine
Returns
Number: the rank of the hand comprised by the card codes, i.e. 1 for FOUR_OF_A_KIND (enumerated in ranks)

rankBoard

Evaluates the given board of 5 to 7 cards provided as part of the board to and then calculates the hand rank.

rankBoard(board: String): Number
Parameters
board (String) the board, i.e. 'Ah Ks Td 3c Ad'
Returns
Number: the rank of the hand comprised by the cards, i.e. 1 for FOUR_OF_A_KIND (enumerated in ranks)

setCardCodes

Converts a set of cards to card codes.

setCardCodes(set: Set<String>): Set<Number>
Parameters
set (Set<String>) card strings set, i.e. Set({'Ah', 'Ks', 'Td', '3c, 'Ad'})
Returns
Set<Number>: card code set

setStringifyCardCodes

Converts a set of card codes to their string representations.

setStringifyCardCodes(set: Set<Number>): Set<String>
Parameters
set (Set<Number>) card code set
Returns
Set<String>: set with string representations of the card codes, i.e. Set({'Ah', 'Ks', 'Td', '3c, 'Ad'})

ranks

Enumeration of possible hand ranks, each rank is a number from 0-8.

STRAIGHT_FLUSH
FOUR_OF_A_KIND
FULL_HOUSE
FLUSH
STRAIGHT
THREE_OF_A_KIND
TWO_PAIR
ONE_PAIR
HIGH_CARD
ranks()

rankDescription

Provides a description of a hand rank number. It's an {Array} which can be indexed into with the hand rank in order to retrieve the matching description.

Example: rankDescription[rank.FULL_HOUSE] === 'Full House'

rankDescription

handRank

Converts a hand strength number into a hand rank number 0 - 8 for STRAIGHT_FLUSH - HIGH_CARD.

handRank(val: Number): Number
Parameters
val (Number) hand strength (result of an evaluate function)
Returns
Number: the hand rank

rankCodes

The ranks of the cards sorted highest to lowest.

  • 2 = 0
  • 3 = 1
  • 4 = 2
  • 5 = 2
  • 6 = 4
  • 7 = 5
  • 8 = 6
  • 9 = 7
  • T = 8
  • J = 9
  • Q = 10
  • K = 11
  • A = 12

6 bits each.

rankCodes
Returns
Object: the ranks indexed as described above

suitCodes

The suitCodes

  • s = 0
  • h = 1
  • d = 2
  • c = 3
suitCodes
Returns
Object: the suits indexed as described above

stringifyCardCode

Converts the given card code into a string presentation.

stringifyCardCode(code: Number): String
Parameters
code (Number) the card code, i.e. obtained via cardCode(rank, suit) .
Returns
String: a string representation of the card in question, i.e. Ah

cardCode

Determines the code for the given hand.

cardCode(rank: String, suit: String): Number
Parameters
rank (String) the rank of the hand, i.e. A
suit (String) the suit of the hand, i.e. h
Returns
Number: the card code that can be used to further evaluate the hand

cardCodes

Determines the code for the given hands.

cardCodes(cards: Array<String>): Array<Number>
Parameters
cards (Array<String>) the cards to convert into card codes, i.e. [ 'Ah', 'Kd' ]
Returns
Array<Number>: the card codes that can be used to further evaluate the hands

boardCodes

Determines the code for the given hands.

boardCodes(board: String): Array<Number>
Parameters
board (String) the board to convert into card codes, i.e. 'Ah Kd Qh'
Returns
Array<Number>: the card codes that can be used to further evaluate the hands