Answered step by step
Verified Expert Solution
Link Copied!

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 3: 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, i.e.2 cards for each player, and the 5 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 (starting_hand) following the "RankSuit" format;
the starting hand of the other players (players_cards), the 2d numpy array returned from the function
generatePlayersCards;
the 5 community cards (dealer_cards), the 1d 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
start_cards, players_cards and dealer_cards and returns a 1d numpy array game_result =
[win, lose, tie] such that:
game_result =[1,0,0] : starting hand wins
game_result =[0,1,0] : another player wins
game_result =[0,0,1] : starting hand ties with another player
Note that you will need to use the function cardNameToInt from Part 1 to convert the given starting_hand
to start_cards.
def whowin(start_cards, players_cards, dealer_cards):
#...
return game_result
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 (player1_cards, player2_cards, dealer_cards):
# player1_cards and player2_cards: 1d numpy array of shape ,
# dealer_cards: 1d numpy array of shape ,)
# do things here...
# Return 0 if player1 cards are better
# Return 1 if player 2 cards are better
# Return 2 if equal
The setup code defines the following variable(s) and/or function(s):
Your code snippet should define the following variable(s) and/or function(s):
image text in transcribed

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Mastering Real Time Analytics In Big Data A Comprehensive Guide For Everyone

Authors: Lennox Mark

1st Edition

B0CPTC9LY9, 979-8869045706

More Books

Students also viewed these Databases questions

Question

What is Accounting?

Answered: 1 week ago

Question

4. Explain the strengths and weaknesses of each approach.

Answered: 1 week ago

Question

3. Identify the methods used within each of the three approaches.

Answered: 1 week ago