Problems? Is your data what you think it is? PerlMonks

### Poker Probability Processor

by Lexicon (Chaplain)
 on May 11, 2001 at 12:48 UTC ( #79660=CUFP: print w/replies, xml ) Need Help??

This started out as (what I expected to be) a tiny program to give me some real poker stats, since I'd recently started learning to play 'real' poker with some friends and I needed to make up for their ability to count cards. Well, it exploded into two math modules, Math::Combinatorics and a freaky thing called Math::Combinatorics::Combinator which is a super generic deck shuffler.
Update4 (2001/7/13 12:18 CST): The Classify_Hand subroutine should be fixed now! The stats are updated as well, with stats I didn't generate. I need to verify my 7 card stud numbers, which will take a couple days, but I'm reasonably confident about the fix for now. If you'd like to know more than you ever wanted to know about poker, try the rec.games.poker faq.

Update3 (2001/5/17 9:04 GST +9): Dominus rules. I indeed forgot the A-2-3-4-5 combinations in the straights! I'll try to correct it this weekend and get this updated. Sorry!

Update2 (2001/5/11 9:32 GST +9): If anyone sees fit to expand my program some, please let me know or post the code here. And the stats as well, of course. ;) I'd like to see how others are using it, as I havn't decided a good path for expansion yet.

Update (2001/5/11 9:28 GST +9): A couple of you were wondering why I chose Brute Force computation. I could use combinatorics (combinatorics were invented for poker actually!). The reason: I plan to teach the package to play games that require 'intelligence', like 5 card draw. I believe this would defeat Combinatorics, but I'll look and see. I will do the Combinatorics to check my math and see if I can be creative enough with them to stats-out 5 card draw. That, and the Perl education was invaluable. I've now learned modules, object orientation, benchmarking, CPAN, Fundamental Benchmarks, Object Oriented Performance, a whole slew of new functions, etc... This is probably the largest program package I've ever written, around 1000 lines all together.

So, all the code is below for you to play with, but I'll spare everyone the suspense...here's the stats:
7 CARD HAND TYPE COUNT Nothing 23,294,460 One Pair 58,627,800 Two Pair 31,433,400 Three of a Kind 6,461,620 Straight 6,180,020 Flush 4,047,644 Full House 3,473,184 Four of a Kind 224,848 Straight Flush 41,584 ------------------------------- 5 CARD HAND TYPE COUNT Nothing 1,302,540 One Pair 1,098,240 Two Pair 123,552 Three of a Kind 54,912 Straight 10,200 Flush 5,108 Full House 3,744 Four of a Kind 624 Straight Flush 36 Royal Flush 4 ------------------------------- 3 CARD HAND TYPE COUNT Nothing 16,440 One Pair 3,744 Three of a Kind 52 Flush 1,096 Straight 720 Straight Flush 48 -------------------------------

Replies are listed 'Best First'.
Re: Poker Probability Processor
by Dominus (Parson) on May 17, 2001 at 02:58 UTC
Says lexicon:
Straight Flush 32 0.00123 Royal Flush 4 0.00015
Seems to me you have a problem here, since there are obviously 40 straight flushes, not 36. Did you perhaps forget A-2-3-4-5?
Straight 9180 0.35322
I think you made the same mistake here also. I count 10,200 straights.

How to locate a good reference (was: Poker Probability Processor)
by tilly (Archbishop) on May 15, 2001 at 16:39 UTC
I know next to nothing about poker.

But my general belief is that anything people put energy into, someone has thought about pretty hard. And if someone has thought about it pretty hard, then someone else (likely several people in fact) has probably put that thought into a book. Given current search tools, it should be possible to locate that book if it is out there. Just look for a book on the topic with good reviews where an independent search on the author comes up with glowing reviews.

And indeed it doesn't take long to run a few searches, sanity cross-check, and find at least one promising candidate that I got from this list. Indeed I suspect that some time spent with any book on that list would be very worthwhile.

Of course take that with a grain of salt. I hate gambling. About all I know about poker is that the purpose of bluffing bad hands is to make it impossible for people to be sure of whether you have a good hand when you do.

But after a short bit of research it isn't much of a gamble to say that David Sklansky is probably a good place to start for trying to learn poker.

Now if we could only convince people trying to learn Perl to use my strategy, some of those bad titles out there might not sell so well... :-(

Re: Poker Probability Processor
by Mungbeans (Pilgrim) on May 15, 2001 at 14:22 UTC
Any chance of something that would tell me what my friends were holding?

Seriously: you may be able to verify statistics from some of the existing poker research.

Where you classify hand, you may be able to optimise this further (this may only make a trivial increase in speed):

1. A pair can't be a flush or a straight so don't do flush processing (in a 5 or 6 card deck, TK in a 7 card deck)
2. Conversely (it may be faster to iterate through flush processing (4 suits vs 13 cards) first but flushes are less frequent than pairs...

Very, very cool. Easy to read and I'm going to snaffle the parameter passing/initialisation for my next script. Thanks for posting this.

Be careful when you go to Vegas ;-)

The big slowdown right now is absolutly in the Flush processing. When I modulize it, I'll be checking into optimizations like you suggest. Classify_Hand takes about twice as long as Combinate. I'm sure (well, hope) I can bring it down an order of magnitude.

The first iteration of a game enhancer version is at least 3 months away. I know what you're looking for, but making it both real-time-fast and accurate enough to be meaningful will be difficult. And then you'll have to convince them to allow your laptop at the table. ;)

Thanks for the input! Let me know how your tweeking goes.

Poker Processor in time for Poker Night!
by knobunc (Pilgrim) on May 11, 2001 at 17:16 UTC

Wow! Cool! Just in time for poker night.

We always have debates about what the odds are for some of the stranger games that we play. Looks like I will have to waste some time this afternoon.

-ben

Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: CUFP [id://79660]
Approved by root
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others examining the Monastery: (9)
As of 2023-12-05 10:54 GMT
Sections?
Information?
Find Nodes?
Leftovers?
Voting Booth?
What's your preferred 'use VERSION' for new CPAN modules in 2023?

Results (26 votes). Check out past polls.

Notices?