Docs Build | |
Documentation | |
GHA CI | |
Code Coverage | |
Bors enabled |
A package for representing playing cards for card games (for a standard deck of fifty two).
A playing Card
is consists of a suit (♣
,♠
,♡
,♢
) and a rank:
Rank(N::Int)
where1 ≤ N ≤ 13
whereN = 1
represents an Ace (which can have high or low values viahigh_value
andlow_value
)N = 11
represents a JackN = 12
represents a QueenN = 13
represents a King
The value of the rank can be retrieved from high_value
and low_value
:
high_value(c::Card) == low_value(c::Card) == c.rank
high_value(::Card) = 14
for Acelow_value(::Card) = 1
for Ace
Card
s have convenience constructors and methods for extracting information about them:
julia> using PlayingCards
julia> card = A♡
A♡
julia> string(card)
"A♡"
julia> suit(A♡)
Heart()
julia> rank(A♠)
Ace()
julia> high_value(A♢)
14
julia> high_value(J♣)
11
julia> low_value(A♡)
1
A Deck
is a struct with a Vector
of Card
s, which has a few convenience methods:
julia> using PlayingCards
julia> deck = ordered_deck()
A♣ 2♣ 3♣ 4♣ 5♣ 6♣ 7♣ 8♣ 9♣ T♣ J♣ Q♣ K♣
A♠ 2♠ 3♠ 4♠ 5♠ 6♠ 7♠ 8♠ 9♠ T♠ J♠ Q♠ K♠
A♡ 2♡ 3♡ 4♡ 5♡ 6♡ 7♡ 8♡ 9♡ T♡ J♡ Q♡ K♡
A♢ 2♢ 3♢ 4♢ 5♢ 6♢ 7♢ 8♢ 9♢ T♢ J♢ Q♢ K♢
julia> shuffle!(deck)
julia> hand = pop!(deck, 2)
(5♣, 8♢)
julia> deck
Q♣ T♣ 5♢ K♠ J♢ 4♢ T♡ K♢ 2♠ 5♠ 2♡ 8♣ 8♠
K♣ T♠ A♣ Q♠ Q♢ 2♢ 7♣ 6♣ J♡ 9♠ 6♢ A♢ 7♠
A♡ 7♡ 3♢ 3♣ 7♢ J♠ 5♡ 4♡ 9♢ 4♣ 3♠ J♣ 6♡
9♡ 6♠ T♢ 3♡ A♠ 8♡ K♡ 2♣ 4♠ Q♡ 9♣
Package | Development status | Purpose |
---|---|---|
PlayingCards.jl | Perhaps stable | Representing cards |
PokerHandEvaluator.jl | Perhaps stable | Comparing any two 5-7 card hands |
TexasHoldem.jl | Likely changes needed | Simulating multi-player games of TexasHoldem |
PokerBots.jl | very early development | Battling bots with prescribed (or learned) strategies |
PokerGUI.jl | very early development | Visualizing TexasHoldem games via a GUI |
Some ideas used here were inspired by