From ce7ed31b5c1b2c62978c772408e98f3ae951b171 Mon Sep 17 00:00:00 2001 From: Donald Calloway Date: Sat, 4 Oct 2025 11:44:50 -0700 Subject: [PATCH] Added code to shuffle deck 7 times --- 5-Card_Stud_Poker_Game (Final).py | 5 +++++ poker.py | 7 +++++-- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/5-Card_Stud_Poker_Game (Final).py b/5-Card_Stud_Poker_Game (Final).py index f70bca0..a7673dd 100644 --- a/5-Card_Stud_Poker_Game (Final).py +++ b/5-Card_Stud_Poker_Game (Final).py @@ -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) diff --git a/poker.py b/poker.py index 162db60..1d86892 100644 --- a/poker.py +++ b/poker.py @@ -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)