Deck
Deck ()
A deck of 52 cards, not including jokers
Deck ()
A deck of 52 cards, not including jokers
When we initially create a deck, all of the cards will 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 defined for a Card
:
We can check if, say, the Ace of Clubs is in the deck:
Deck.pop (idx:int=-1)
Remove one card from the deck
Type | Default | Details | |
---|---|---|---|
idx | int | -1 | The index of the card to remove, defaulting to the last one |
There are 51 cards left in the deck now.
Deck.remove (card:nbdev_cards.card.Card)
Removes card
from the deck or raises exception if it is not there
Type | Details | |
---|---|---|
card | Card | Card to remove |
Deck.shuffle ()
Shuffles the cards in this deck
draw_n (n:int, replace:bool=True)
Draw n
cards, with replacement iif replace
Type | Default | Details | |
---|---|---|---|
n | int | number of cards to draw | |
replace | bool | True | whether or not draw with replacement |