Question: Show me the steps to solve Create a function called compare _ hands ( agent _ hand, dealer _ hand ) that does the following:
Show me the steps to solve
Create a function called comparehandsagenthand, dealerhand that does the following:
Accepts parameters:
agenthand of type list that represents the cards in the agents hand
dealerhand of type list that represents the cards in the dealer's hand
Determine the winner based on these rules:
If the agenthand value is over the player busts, and the dealer wins.
If the dealerhand value is over the dealer busts, and the player wins.
If the agenthand value is higher than the dealers the player wins.
If the dealerhand value is higher than the players the dealer wins.
If both have the same value, its a push a tie
Returns the result of the comparison as a string egPlayer busts!
Replace your existing main function from the previous parts with one that does the following:
Prompts the user to enter a filename.
Call the readdeck function with filename as an argument to obtain the deckofcards.
Call the shuffle function with deckofcards as an argument to obtain shuffleddeck.
Uses a while statement to repeatedly play the game until the number of cards left in the shuffleddeck is less than or equal to Each iteration of the loop should follow these steps:
Initialization
Call the dealcard function with shuffleddeck and numberofcards as arguments to obtain agenthand. Set numberofcards to to give the agent an initial hand of cards.
Call the dealcard function with shuffleddeck and numberofcards as arguments to obtain dealerhand. Set numberofcards to to give the dealer an initial hand of cards.
Play Hands
Call the playhand function with agenthand and shuffleddeck as arguments to update agenthand.
Call the playhand function with dealerhand and shuffleddeck as arguments to update dealerhand.
Compare Hands
Call the comparehands function with agenthand and dealerhand as arguments to obtain the result of the game.
Print the result of comparehands.
Sample output
Enter filename: decktxt
Dealer busts!
Dealer wins!
Dealer busts!
Dealer busts!
Player wins!
Player busts!
Dealer busts!
Push!
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
