June 2019
Beginner to intermediate
770 pages
19h 24m
English
In a casino, cards are often dealt from a shoe that has half a dozen decks of cards all mingled together. This additional complexity suggests that we need to build our own implementation of Deck and not simply use the list class directly. Additionally, a casino shoe is not dealt fully. Instead, a marker card is inserted. Because of the marker, some cards are effectively set aside and not used for play. These cards are said to be burned.
The following Deck3 class definition contains multiple sets of 52-card decks:
class Deck3(list): def __init__(self, decks: int = 1) -> None: super().__init__() for i in range(decks): self.extend( card(r + 1, s) for r in range(13) for s in iter(Suit) ) random.shuffle(
Read now
Unlock full access