Johnny the Poker Player - What is my equity?
Description:
Meet Johnny.
He is a recreational Poker Player and started playing No-Limit Texas Hold'em Poker during the Poker Boom fuelled by the Moneymaker effect.
Johnny has a natural ability to read cards and situations and also has the heart to pull off the occasional bluff. These innate talents have served him well in the past but lately, he is on a losing streak.
Johnny is a "feel-player" and lets his instintcs and gut decide the course of action rather than math. He heard some terms thrown around in conversations between professional players like: "Pot Odds", "Equity" or "Expected Value" and wants to find out how to let math decide his actions and rely less on instintcs and luck to turn his streak around. Luckily you are his friend and you know about math and solving problems so he turns to you with a set of questions.
In every form of Poker, each one of the 3 possible actions (Call, Fold or Raise) has an expected value (EV). EV is defined as the amount of money an action expects to win or lose on average.
But before you can help Johnny calculate the expected value for a given situation, we need to know how Johnny's hands hold up against his opponent's hands to figure out his equity in the pot. Equity is defined as the share of the current pot which belongs to the player based on the probability of winning the hand after all cards are dealt (showdown.
Johnny finds himself frequently in a situation where he has a draw but doesn't quite know the probability of winning the hand against his opponent's hand. For example, Johnny holds A<span style=’color: black’>♠3<span style=’color: black’>♠ and the board reads J<span style=’color: black’>♠9<span style=’color: black’>♠K<span style=’color: red’>♥ and he is very certain his opponent is holding K<span style=’color: red’>♥K<span style=’color: red’>♦. He would like to know the chances of winning the hand if he gets to see 2 more cards. Any spade which doesn't pair the board gives him the winning hand in form of a flush (if the board pairs, his opponent makes a full house) and if the Q and 10 come on the turn and river, he also makes a straight. Thus he holds a flush draw and a backdoor straight draw on the flop. Johnny asks you: "What is my equity?" which is the first kata in a series of katas where you help Johnny with poker related questions.
Write a function for Johnny called get_equity()
with the following positional arguments of type list containing strings representing each card: board
(can be empty if Johnny wants to evaluate pre-flop equity), hero
(Johnny's cards) and villain
(opponent's cards) which returns the chance in percent of Johnny's hand winning at showdown (flop, turn, river).
For all situations where Johnny already knows the flop (or flop and turn) the number returned needs to be exact for 2 decimal places. For a situation where Johnny has not yet seen the flop (called pre-flop), he is ok with a good estimate, so the number returned can be in the range of 2% of the actual number.
For the example above where Johnny has a flush draw and a backdoor straight draw, the function would be called like this:
get_equity(['JS', '9S', 'KH'], ['AS', '3S'], ['KS', 'KD'])
and it would return 25.45
as Johnny's hand has 25.45% equity in the pot on the flop.
For pre-flop situations, the function would be called with an empty board:
get_equity([], ['AH', 'KD'], ['QH', 'QD'])
and it would return a number between 41.65
and 45.65
as the precise equity for Johnny's hand is 43.65%
Hand rankings are listed here. Ties are resolved by comparing the remaining cards in the hand.
We assume that Johnny knows his opponent's hand because his opponents play very transparently. In a later kata we will need to compute our equity vs a range of hands.
Similar Kata:
Stats:
Created | Nov 10, 2017 |
Published | Nov 10, 2017 |
Warriors Trained | 47 |
Total Skips | 0 |
Total Code Submissions | 76 |
Total Times Completed | 4 |
Python Completions | 4 |
Total Stars | 3 |
% of votes with a positive feedback rating | 100% of 1 |
Total "Very Satisfied" Votes | 1 |
Total "Somewhat Satisfied" Votes | 0 |
Total "Not Satisfied" Votes | 0 |