Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Part 3 : Determining if you have a winning hand Our goal is to determine the odds of winning for your starting hand. We will
Part : Determining if you have a winning hand
Our goal is to determine the odds of winning for your starting hand. We will be calling a game the dealing of
all the opponent cards, ie cards for each player, and the dealer cards. For each game, you will determine
if your hand wins the game, if another player wins, or if there is a tie.
The setup code will generate the variables needed for one game:
your starting hand startinghand following the "RankSuit" format;
the starting hand of the other players playerscards the numpy array returned from the function
generatePlayersCards;
the community cards dealercards the d numpy array returned from the function
generateDealerCards.
For each game, you will cycle through all the other players hands and if you lose to any one of them, your
starting hand loses. If you win against all of them, your starting hand wins. If you tie against some of them
and win against the others, that is a tie.
Your code snippet should define the function whowin that takes as arguments the numpy arrays
startcards, playerscards and dealercards and returns a d numpy array gameresult
win lose, tie such that:
gameresult : starting hand wins
gameresult : another player wins
gameresult : starting hand ties with another player
Note that you will need to use the function cardNameToInt from Part to convert the given startinghand
to startcards.
def whowinstartcards, playerscards, dealercards:
#
return gameresult
To help you determine the best hand that wins a game, we provide you with the function compareTwoPlayers
that takes the cards of two different players and the community cards, and gives you who has the best
hand. The function is defined as:
def compareTwoPlayers playercards, playercards, dealercards:
# playercards and playercards: d numpy array of shape
# dealercards: numpy array of shape
# do things here...
# Return if player cards are better
# Return if player cards are better
# Return if equal
The setup code defines the following variables andor functions:
Your code snippet should define the following variables andor functions:
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started