org.pokersource.game
Class Deck
java.lang.Object
org.pokersource.game.Deck
public class Deck
extends java.lang.Object
Some utilities for working with cards and cardmasks in a way that is
consistent with all decks used by the poker-eval C library. We use
the joker deck because it is a superset of the other decks.
static String | cardMaskString(long mask) - Returns a string like "Ac Td 2h" representing the cards in mask.
|
static String | cardMaskString(long mask, String delim) - Returns a string like "Ac Td 2h" representing the cards in mask.
|
static String | cardString(int rank, int suit) - Returns a string like "Ac", "Td", or "2h" representing the card.
|
static int | createCardIndex(int rank, int suit) - Returns a number between 0 and 52 denoting the card index within
the deck.
|
static long | createCardMask(int rank, int suit) - Returns a long integer with one bit set corresponding to the card
index.
|
static long | createCardMask(int[] ranks, int[] suits) - Returns a long integer with one bit set for each card present in
the ranks/suits arrays.
|
static int | numCards(long mask)
|
static long | parseCardMask(String maskstr) - Returns a long integer with one bit set for each card present in
the input string.
|
static int | parseRank(String rankstr)
|
static int | parseSuit(String suitstr)
|
static String | rankString(int rank)
|
static String | suitString(int suit)
|
RANK_2
public static int RANK_2
RANK_3
public static int RANK_3
RANK_4
public static int RANK_4
RANK_5
public static int RANK_5
RANK_6
public static int RANK_6
RANK_7
public static int RANK_7
RANK_8
public static int RANK_8
RANK_9
public static int RANK_9
RANK_ACE
public static int RANK_ACE
RANK_COUNT
public static int RANK_COUNT
RANK_JACK
public static int RANK_JACK
RANK_JOKER
public static int RANK_JOKER
RANK_KING
public static int RANK_KING
RANK_QUEEN
public static int RANK_QUEEN
RANK_TEN
public static int RANK_TEN
SUIT_CLUBS
public static int SUIT_CLUBS
SUIT_COUNT
public static int SUIT_COUNT
SUIT_DIAMONDS
public static int SUIT_DIAMONDS
SUIT_HEARTS
public static int SUIT_HEARTS
SUIT_JOKER
public static int SUIT_JOKER
SUIT_SPADES
public static int SUIT_SPADES
cardMaskString
public static String cardMaskString(long mask)
Returns a string like "Ac Td 2h" representing the cards in mask.
mask
- The bitmask of cards in the hand (from createCardMask())
- string representation of the cards
cardMaskString
public static String cardMaskString(long mask,
String delim)
Returns a string like "Ac Td 2h" representing the cards in mask.
mask
- The bitmask of cards in the hand (from createCardMask())delim
- Delimiter to insert between each card (example above uses " ")
- string representation of the cards
cardString
public static String cardString(int rank,
int suit)
Returns a string like "Ac", "Td", or "2h" representing the card.
rank
- The rank of the cardsuit
- The suit of the card
- string representation of the card
createCardIndex
public static int createCardIndex(int rank,
int suit)
Returns a number between 0 and 52 denoting the card index within
the deck. Consistent with all of StdDeck, JokerDeck, and AStudDeck
in the poker-eval C library.
rank
- The rank of the cardsuit
- The suit of the card
createCardMask
public static long createCardMask(int rank,
int suit)
Returns a long integer with one bit set corresponding to the card
index. Consistent with all of StdDeck, JokerDeck, and AStudDeck
in the poker-eval C library.
rank
- The rank of the cardsuit
- The suit of the card
- bitmask with one bit set between bits 0 and 52
createCardMask
public static long createCardMask(int[] ranks,
int[] suits)
Returns a long integer with one bit set for each card present in
the ranks/suits arrays. Consistent with all of StdDeck, JokerDeck,
and AStudDeck in the poker-eval C library.
ranks
- ranks[i] is the rank of the ith cardsuits
- suits[i] is the suit of the ith card
numCards
public static int numCards(long mask)
parseCardMask
public static long parseCardMask(String maskstr)
Returns a long integer with one bit set for each card present in
the input string. Consistent with all of StdDeck, JokerDeck,
and AStudDeck in the poker-eval C library.
maskstr
- One or more cards, e.g., "Ac Td 2h" (whitespace optional)
parseRank
public static int parseRank(String rankstr)
parseSuit
public static int parseSuit(String suitstr)
rankString
public static String rankString(int rank)
suitString
public static String suitString(int suit)
PokerSource Home Page - Learn how you can contribute!