-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDeck.py
30 lines (24 loc) · 793 Bytes
/
Deck.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
import random
from numpy.random.mtrand import rand
class Deck:
def __init__(self):
self.seed = 0
self.shuffle_deck()
def draw_card(self, card_to_drawn=0) -> int:
if card_to_drawn != 0:
self.cards.remove(card_to_drawn)
card = card_to_drawn
else:
r = random.randint(0, len(self.cards) - 1)
card = self.cards.pop(r)
if card % 10 == 0:
self.card_count[10] -= 1
else:
self.card_count[card % 10] -= 1
return card
def shuffle_deck(self):
# self.seed += 1
# random.seed(self.seed)
self.cards = [card for card in range(1, 41)]
random.shuffle(self.cards)
self.card_count = dict.fromkeys([i for i in range(1, 11)], 4)