Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

in python please The game is played by two players. A deck of cards is put face

ID: 3747441 • Letter: I

Question

in python please

The game is played by two players. A deck of cards is put face down and a random card is drawn from the deck, both players see the trump suit and the card is put back into a random place into the deck. At each turn: players grab one card each from the top of the deck and put them face up on the table. If both cards have the same suit, then the player with the highest ranked card wins this turn, takes this pair of cards and places them into his/her pile If cards have different suits, then the person with a trump card wins his turn, takes this pair of cards and places them into his/her pile If the cards have different suits and none of them is a trump, then it is a tie, the cards are discarded.

Explanation / Answer

from enum import Enum from enum import IntEnum from random import * # Initialization full_deck = [] partial_deck = [] player1_cards = [] player2_cards = [] class Card(IntEnum): TWO=2 THREE=3 FOUR=4 FIVE=5 SIX=6 SEVEN=7 EIGHT=8 NINE=9 TEN=10 JACK=11 QUEEN=12 KING=13 ACE=14 class Suit(Enum): SPADES = 'spades' CLUBS = 'clubs' HEARTS = 'hearts' DIAMONDS = 'diamonds' # Class to hold information for playing cards class PlayingCard: def __init__(self, card_value, card_suit): self.card = card_value self.suit = card_suit # Function to deal full deck of cards def create_deck(): for suit in Suit : for card in Card: full_deck.append(PlayingCard((Card(card), Suit(suit)))) return full_deck # Deal two players for the game def deal_war(): while(len(partial_deck>0)): player1_cards.append(draw_card(partial_deck)) player2_cards.append(draw_card(partial_deck)) create_deck() partial_deck = list(full_deck) deal_war() # Function to draw single card from deck def draw_card(deck): rand_card = randint(0,len(deck)-1) return deck.pop(rand_card) for i in range(0, len(player1_cards)): if(player1_cards[i].card > player2_cards[i].card): print("Player 1 wins the hand with:", player1_cards[i].card) print("Player 2 loses with:", player2_cards[i].card) if (player1_cards[i].card