I've been reading about outs and its hard to tell what is the exact formula for getting them. Is there a formula for calculating outs? I want to add a functionality to my app where players can see their Outs.
So there's a real mathematical way and there's a standard poker way.
There's two parts:
1) Counting potential "out" cards.
2) Calculating the chances of getting these "out" cards for each street left to deal.
Imagine a simple situation. You have 44 preflop, you 3xBB raise on button. A short stack goes Allin 15xBB. Everyone else folds.
Flop comes A, 2, 3.
So first step is counting potential "outs". One would imagine that it's likely 44 is no good in that situation giving the majority of a re-raise Allin probably contain a bigger pair and/or an Ace. You can basically imagine you need either another 4 for trips OR a 5 for a straight. This part of counting "Outs" is logic and guessing. The opponent could have KQ in which case you need no "Outs" or he could have AA or even 45, in which case you are pretty much drawing dead (barring runner runner 4, or 45 for a draw). For simplicity's sake, let's imagine either 4 or 5 will give you the win. So you have two 4s left and four 5s left. Keep in mind that in math/logic, what you don't see, you don't know. So you cannot pretend another player had folded a 4, because he could also have folded a Q, overall, what the other players might have folded DO NOT factor into the universal math calculation in poker odds.
2) Calculating Odds. So you have 6 "outs" (two 4s and four 5s). There are 47 cards that are still unknown to you (again, you do not guess what the opponent could be holding because in the long run, it does not matter). Your chance of getting an "out" on the TURN card is 6/47 = 12.76%. If you miss the turn, your chance of improving on the RIVER would be 6/46 = 13.04%.
Now most poker players of today's world use OTHER PEOPLE'S math because let's face it, there aren't that many mathematicians playing poker as we might think (because we have existing calculations and theories). So most poker player simply ESTIMATE the odds by doing "outs" x 2 percentage. So if you have 6 outs, your percentage of winning on TURN is approximately 6 x 2 = 12% (which is close to the actual math).
So in summary, for your code, use real math; but for real life, generally "outs times two" is a good enough estimate of win percentage.
Outs are all cards, which will give you the lead. Unfortunately you do not know the hand(s) from your opponent(s) so you do not know which cards are outs for sure.
Example: You hold 5s6s Opponent TsJs Flop 2sKsAh
You have 6 Outs, but you might think that you have 9 outs vs a pair (9 Spades, disregarding AsXs). If your opponent would hold 22/KK/AcAd you had to discount the As making it 8 outs.
Outs = The unknown cards left in a deck of 52 cards that if dealt will change a current poker hand's probability of winning or losing .