Reputation: 101
I am currently making a simulation about poker in python and I am stucked at calculating outs at post-flop, turn
I want to learn how to calculate the outs when flop is drawn. In other way I want to learn how to make my simulation recognize that I need one card to have straight. If the missing card is in the middle, my outs would be 4. If it is at the beginning or end of the straight my outs would be 8.
For Example:
I have in my pocket(hands) 5-Spades and 6-Diamond
The flop is: 9-Clubs , 8-Hearts , K-Hearts
So my 5-Card hand is like: 5s - 6d - 8h - 9c - Kh
In Poker this draw is a gutshot straight draw. If I draw any kind of 7 in turn or river, I will have straight draw. Since there are 4 7s in a deck, my outs are 4 to have the Straight.
This is only one and basic example about outs.
If anyone can guide me, I will be pleased.
Kind Regards
Upvotes: 1
Views: 1650
Reputation: 21364
First, you need some code that can recognize the various hands (four-of-a-kind, straight flush, etc.). Then, your algorithm should take four cards at a time from the player's hand, and cycle through all of the remaining cards in the deck, one at a time, adding them to the player's hand and testing them to see which hands are possible with one draw.
That is, given the hand A B C D E
, so that cards X1, X2, ..., X47
constitute the possible draws, your algorithm will test:
A B C D + (X1 ... X47) --> evaluate_hand()
A B C E + (X1 ... X47) --> evaluate_hand()
A B D E + (X1 ... X47) --> evaluate_hand()
A C D E + (X1 ... X47) --> evaluate_hand()
B C D E + (X1 ... X47) --> evaluate_hand()
If one of these 235 hands evaluates to STRAIGHT_FLUSH
, you will know that the player is one card away from a straight flush.
Upvotes: 1
Reputation: 7824
With no other knowledge you can work out the probabilities using
number of ways a success can occur
-----------------------------------
total number of outcomes
So there are 5 cards you know about and 52-5 = 47 card you don't know giving 47 possible outcomes. To draw one of the 4 sevens the probability will be
4
--
47
If two cards are drawn it, you then need to probability tree diagrams
For the first two cards to be 7's the probability will be
4 / 47 * 3 / 46
for the first to be a 7 and the second not to be a seven its
4 / 47 * 43 / 46
for the first not to be a seven and the second to be a seven its
43 / 47 * 4 / 46
for neither to be sevens its
43 / 47 * 42 / 46
Upvotes: 0