API
Card
PlayingCards.Suit
— TypeSuit
Encode a suit as a 2-bit value (low bits of a UInt8
):
- 0 = ♣ (clubs)
- 1 = ♢ (diamonds)
- 2 = ♡ (hearts)
- 3 = ♠ (spades)
Suits have global constant bindings: ♣
, ♢
, ♡
, ♠
.
PlayingCards.Card
— TypeCard
Encode a playing card as a 6-bit integer (low bits of a UInt8
):
- low bits represent rank from 0 to 15
- high bits represent suit (♣, ♢, ♡ or ♠)
Ranks are assigned as follows:
- numbered cards (2 to 10) have rank equal to their number
- jacks, queens and kings have ranks 11, 12 and 13
- there are low and high aces with ranks 1 and 14, 0 is for Joker
- there are low and high jokers with ranks 0 and 15
This allows any of the standard orderings of cards ranks to be achieved simply by choosing which aces to use.
There are a total of 64 possible card values with this scheme, represented by UInt8
values 0x00
through 0x3f
.
PlayingCards.suit
— Functionsuit(::Card)
The suit of a card
PlayingCards.rank
— Functionrank(::Card)
The rank of a card
PlayingCards.high_value
— Functionhigh_value(::Card)
high_value(::Rank)
The high rank value. For example:
Rank(1)
-> 14 (uselow_value
for the low Ace value.)Rank(5)
-> 5
PlayingCards.low_value
— Functionlow_value(::Card)
low_value(::Rank)
The low rank value. For example:
Rank(1)
-> 1 (usehigh_value
for the high Ace value.)Rank(5)
-> 5
PlayingCards.color
— Functioncolor(::Card)
A Symbol
(:red
, or :black
) indicating the color of the suit or card.
Auxiliary methods
PlayingCards.full_deck
— Functionfull_deck
A vector of a cards containing a full deck
PlayingCards.ranks
— Functionranks
A Tuple of ranks 1:13
.
PlayingCards.suits
— Functionsuits
A Tuple of all suits
Deck
PlayingCards.Deck
— TypeDeck
Deck of cards (backed by a Vector{Card}
)
PlayingCards.ordered_deck
— Functionordered_deck
An ordered Deck
of cards.
Base.pop!
— Functionpop!(deck::Deck, n::Int = 1)
pop!(deck::Deck, card::Card)
Remove n
cards from the deck
. or Remove card
from the deck
.
Random.shuffle!
— Functionshuffle!
Shuffle the deck! Optionally accepts an AbstractRNG
to seed the shuffle.