Added time() module and code to randomize the seed for random shuffling.
This commit is contained in:
parent
5406155c5d
commit
f066fe8bb1
@ -1,6 +1,7 @@
|
||||
import random
|
||||
from collections import defaultdict
|
||||
from itertools import combinations
|
||||
import time
|
||||
|
||||
# Define card ranks and their order for runs
|
||||
RANK_ORDER = {str(n): n for n in range(2, 11)}
|
||||
@ -26,6 +27,7 @@ class Card:
|
||||
class Deck:
|
||||
def __init__(self):
|
||||
self.cards = [Card(rank, suit) for suit in Card.suits for rank in Card.ranks]
|
||||
random.seed(time.time()) # Seed random number generator with current time
|
||||
random.shuffle(self.cards)
|
||||
|
||||
def draw(self):
|
||||
@ -112,7 +114,7 @@ class Game:
|
||||
self.deal()
|
||||
print("Initial hands:")
|
||||
for p in self.players:
|
||||
print(p.name, p.hand)
|
||||
print(f"{p.name}'s {p.hand}")
|
||||
|
||||
|
||||
# Function to detect sets
|
||||
|
||||
Loading…
Reference in New Issue
Block a user