Added code to shuffle deck 7 times

This commit is contained in:
Donald Calloway 2025-10-04 11:44:50 -07:00
parent 5be329909a
commit ce7ed31b5c
2 changed files with 10 additions and 2 deletions

View File

@ -4,6 +4,7 @@ import random
import time
from collections import Counter
from hand_utils import evaluate_hand, Tuple, List, Card, SUITS, RANKS
import copy
starting_chips = 0 # Default starting chips for each player
rank_counts = Counter()
@ -227,6 +228,10 @@ class Deck:
self.cards: List[Card] = [Card(rank, suit) for suit in SUITS for rank in RANKS]
random.seed(time.time()) # Seed random number generator with current time
random.shuffle(self.cards)
deck_copy = copy.deepcopy(deck)
for _ in range(7): # Shuffle the deck 7 times
random.shuffle(deck_copy)
deck = deck_copy
def deal_card(self) -> Card:
return self.cards.pop(0)

View File

@ -1,5 +1,6 @@
import random
from typing import List, Tuple
import copy
SUITS = ['Hearts', 'Diamonds', 'Clubs', 'Spades']
RANKS = ['2', '3', '4', '5', '6', '7', '8', '9', '10', 'J', 'Q', 'K', 'A']
@ -131,8 +132,10 @@ def display_hands(player1: Hand, player2: Hand):
def main():
deck = create_deck()
random.shuffle(deck)
random.shuffle(deck)
deck_copy = copy.deepcopy(deck)
for _ in range(7):
random.shuffle(deck_copy)
deck = deck_copy
player1 = deal_hand(deck)
player2 = deal_hand(deck)
display_initial_hands(player1, player2)