PDA

View Full Version : Monte Carlo vs Possible Equation?


jhaluska
07-27-2003, 12:16 AM
In Hold`em, I'm trying to calculate the preflop odds of any hand beating another single hand. For example, say I have the hand 7 /images/graemlins/diamond.gif, 8 /images/graemlins/spade.gif and I want to know the chance of beating K /images/graemlins/spade.gif, 3 /images/graemlins/club.gif. Currently I'm trying millions of monte carlo simulations, but I was wondering if there was a formula I could use to compute it exactly?

FastCards
07-27-2003, 05:58 AM
There are 48 cards left. To get an exact answer you need to deal every possible flop combination and evaluate the two hands with each flop.

The number of flops is (48*47*46*45*44)/(5*4*3*2*1)
=1,712,304

I haven't come across a formula to calculate the exact answer without dealing all the flops. If such a formula exists I would think it would be rather complicated if it was designed to deal with any heads-up situation (as opposed to just 7h8s v Ks3c). Please correct me if I am wrong about this.

One (rough) way to deal all the flops programmatically:

1. Use an array of cards numbered 1 to 52.
2. Give each card a number, e.g. As=1, Ks=2....2h=52 etc
3. Take the players' cards out of the array leaving 48 cards
4. With the remaining 48 cards, use nested loops to get every possible combination.
5. Within the loops evaluate each hand with each flop and tally the results.

e.g.
for a=1 to 48 do
for b=a+1 to 48 do
for c=b+1 to 48 do
for d=c+1 to 48 do
for e=d+1 to 48 do
EvaluateFlop(Crd[a],Crd[b],Crd[c],Crd[d],Crd[e])

The values for a,b,c,d,e generated by the loop will be

1,2,3,4,5
1,2,3,4,6
1,2,3,4,7
....
2,3,4,5,6
2,3,4,5,7
...
...
44,45,46,47,48.

This gives you every possible combination. With a bit of thought you can extend this to allow for more than 2 players and/or 1 or more board cards.

I'm pretty sure that there are examples of this type of thing in the public domain.

Regards
Fast Cards

jhaluska
07-27-2003, 09:30 AM
Actually my program already has the card numbering and I considered doing exactly that. Except I miscalculated how long it would take.

[ QUOTE ]
We took the data the Pokalyzer can generate from the simple operation above and ran every hand against every other hand which required over seven billion hand evaluations and took us two weeks.

[/ QUOTE ]

Sounds like you have some experience with the problem. /images/graemlins/smile.gif

FastCards
07-27-2003, 11:27 AM
To deal every heads-up combination with every flop...

There are 169 starting hands (using Spades if suited, Spades and hearts if offsuit. The results are identical for other suit combinations).

Each of the 169 hands can play against 1225 other starting hands.

169*1225 = 207,025 match-ups.

With 48 cards left there are 1,712,304 flop combinations.

207,025 8 1,712,304 = 354,489,735,600

You need to evaluate both hands so double that figure to get

708,979,471,200 (just over 700 billion)

So it is 700bil hands, not 7bil. Processing took just over a week. The key is obviously to get your hand evaluation function fine tuned.

From a programming perspective it was an interesting challenge....

droidboy
07-27-2003, 11:53 AM
[ QUOTE ]
We took the data the Pokalyzer can generate from the simple operation above and ran every hand against every other hand which required over seven billion hand evaluations and took us two weeks.

[/ QUOTE ]

Sounds like you have some experience with the problem. /images/graemlins/smile.gif

[/ QUOTE ]

He probably does, but it shouldn't take two weeks if you are clever.

Try PokerStove (http://www.pokerstove.com) if you are looking for software that is an order of magnitude faster.

droidboy
07-27-2003, 11:59 AM
[ QUOTE ]
To deal every heads-up combination with every flop...

Each of the 169 hands can play against 1225 other starting hands.

169*1225 = 207,025 match-ups.

So it is 700bil hands, not 7bil. Processing took just over a week.

From a programming perspective it was an interesting challenge....

[/ QUOTE ]

It was an interesting challenge. It took me a few months to get my hand evaluator ramped up to speed. But once it was done, it took two hours to calculate all heads-up match-ups, not one week.

FastCards
07-27-2003, 01:57 PM
Congratulations to you for achieving such fast code.

In our scenario, speed was not important because we used the results from the 700bil hands to build a data table showing the results of all heads-up combinations for all possible flops. The data table is supplied with the software mercifully preventing the user for sitting for 8 days twiddling their thumbs.

Regards
Fast Cards

droidboy
07-27-2003, 06:23 PM
[ QUOTE ]
Congratulations to you for achieving such fast code.

In our scenario, speed was not important because we used the results from the 700bil hands to build a data table showing the results of all heads-up combinations for all possible flops. The data table is supplied with the software mercifully preventing the user for sitting for 8 days twiddling their thumbs.

Regards
Fast Cards

[/ QUOTE ]

I understand the amount of work that it takes to get all that data. And I certainly agree that solving that kind of problem is interesting. There are a lot of interesting things you can ask about poker, and equities. Coming up with specific answers to various scenarios is especially important when those sencarios come up regularly. Using precomputed solutions in these cases is exactly what you want to do.

But there are so many possible permutations on the problem that having a fast general solution is good as well. For example: how does AA fare versus KK when an ace has been exposed by a careless dealer? What about KK versus an opponent that caps preflop with AA/KK or AK?

FastCards
07-27-2003, 09:19 PM
Absolutely, a fast soluton is a pre-requisite.

The software uses the pre-compiled data files for the Heads-up listings only. You can also setup between 1 and 10 hands and (optional) board cards. In this scenario, every board combination is dealt and tabulated on the spot. Heads up with no flop (1,712,304 board combos) takes about 2 seconds (my first attempt was 24 seconds...). As well as the overall win/split/lose numbers it also records how many times each player hits a specific hand (flush, straight etc) and also how many times they win with each specific hand.