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

how do I go about doing this in python? Implement the card game described below.

ID: 3669861 • Letter: H

Question

how do I go about doing this in python? Implement the card game described below. 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 dierent 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 dierent suits and none of them is a trump, then it is a tie, the cards are discarded.

Explanation / Answer

Note:As per your requirement code has developed in python

import cardsBasic

#You generate a Deck instance, which is filled (repeatedly) with 52 Card instances

hi_deck = cardsBasic.Deck()

print("======messy print a deck=====")

print(hi_deck)

print("======cute print a deck=====")

hi_deck.cute_print()

#CHANGE THE ORDER THE CARDS

hi_deck.shuffle()

print("======shuffled deck=====")

hi_deck.cute_print()

a_card = hi_deck.deal()

#SHOW THE CARDS

print("Dealt card is:",a_card)

print('How many cards left:',hi_deck.cards_count())

#USER ENTER THE DETAILS

print("Whether the deck empty?",hi_deck.is_empty())

# COMPACT A LITTLE HANDS AND PRINT

hand1_list=[]

hand2_list=[]

#DISPLAY THE WEIGHT

for m in range(5):

    hand1_list.append(hi_deck.deal())

    hand2_list.append(hi_deck.deal())

                     

print(" Hand 1:", hand1_list)

print("Hand 2:", hand2_list)

print()

# take the last card dealt out of each hand

last_card_hand1 = hand1_list.pop()

last_card_hand2 = hand2_list.pop()

print("Hand1 threw down",last_card_hand1, ", Hand2 threw down", last_card_hand2)

print("Hands are now:",hand1_list, hand2_list)

# check the compares

if last_card_hand1.equal_rank(last_card_hand2):

    print(last_card_hand1, last_card_hand2, "of equal rank")

elif last_card_hand1.get_rank() > last_card_hand2.get_rank():

    print(last_card_hand1, "of higher rank than",last_card_hand2)

else:

    print(last_card_hand2, "of higher rank than",last_card_hand1)

if last_card_hand1.equal_value(last_card_hand2):

    print(last_card_hand1, last_card_hand2, "of equal value")

elif last_card_hand1.get_value() > last_card_hand2.get_value():

    print(last_card_hand1, "of higher value than",last_card_hand2)

else:

    print(last_card_hand2, "of higher value than",last_card_hand1)

if last_card_hand1.equal_suit(last_card_hand2):

    print(last_card_hand1,'of equal suit with',last_card_hand2)

else:

    print(last_card_hand1,'of different suit than',last_card_hand2)

# List display.

foundation_list = [[],[],[],[]]

#Display the columns

column = 0

#LOOP

while not hi_deck.is_empty():

    foundation_list[column].append(hi_deck.deal())

    column += 1

     #Condition

    if column % 4 == 0:

        column = 0

     #LOOP

for m in range(4):

    print("foundation",m,foundation_list[m])