source
Deck
Deck ()
Initialize self. See help(type(self)) for accurate signature.
When we create a deck, all of the cards should be present
A♣️; 2♣️; 3♣️; 4♣️; 5♣️; 6♣️; 7♣️; 8♣️; 9♣️; 10♣️; J♣️; Q♣️; K♣️; A♦️; 2♦️; 3♦️; 4♦️; 5♦️; 6♦️; 7♦️; 8♦️; 9♦️; 10♦️; J♦️; Q♦️; K♦️; A♥️; 2♥️; 3♥️; 4♥️; 5♥️; 6♥️; 7♥️; 8♥️; 9♥️; 10♥️; J♥️; Q♥️; K♥️; A♠️; 2♠️; 3♠️; 4♠️; 5♠️; 6♠️; 7♠️; 8♠️; 9♠️; 10♠️; J♠️; Q♠️; K♠️
That should be 52 cards
As a reminder, these are the suits
We can check if, e.g. the Ace of Clubs is in the deck
source
Deck.pop
Deck.pop (idx:int=-1)
Remove one card from the deck
idx |
int |
-1 |
The index of the card to remove, defaulting to the last one |
deck = Deck()
test_eq(deck.pop(), Card(3,13)) # K♠️
source
Deck.shuffle
Deck.shuffle ()
Shuffles the cards in this deck
source
Deck.remove
Deck.remove (card:nbdev_cardtest.card.Card)
Removes card
from the deck or raises exception if it is not there
card23 = Card(2, 3)
deck.remove(card23)
assert card23 not in deck