Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsGeneralPHPASPPerlColdFusionFlashHTML, CSS, ScriptsBrowsers

Re: Poker hand evaluator



Tip: Looking for answers? Try searching our database.



You are accessing this site in a read-only mode. For full access to all member benefits, including message posting, please login or register. Registration is completely free, simple, and takes only a few seconds.

Login | Free WebmasterKB.com registration | Whole discussion thread

The message you are replying to and its parents are listed in the reverse order with the most recent posts first. This might not be the whole discussion thread. To read all the messages in this thread please click here.

Re: Poker hand evaluator

Scott Sauyet09 Mar 2010 21:45
> Has anybody written a fast Texas hold'em hand evaluator in ECMAScript?

I never have, and would not choose ES to code one without good reason.

If issues of speed are not that important, this would not be hard to
code, either in the compare-two-hands version or the score-a-hand
version.

But it sounds like you're looking for something optimized for speed.
I don't think many ES implementation are optimized for numeric
calculations of that sort.

> (NB: this is Texas hold'em, with 7 cards. Naive assumptions from 5 card
> poker do not necessarily apply. There may be a flush and a straight,
> but no straight flush. Also, there may be both 4 of a kind and 3 of
> a kind, etc. What is wanted is the value of the best 5 cards subset.)

There are only twenty-one 5-card hands that can be made from a 7-card
hand, so it would be reasonable to simply do a maximum score on those
sub-hands to make a 7-card hand evaluator out of a 5-card hand one.
But again, this means 21 runs of the 5-card hand evaluator, clearly
not a technique optimized for speed.

 -- Scott

Johannes Baagoe09 Mar 2010 15:22
Has anybody written a fast Texas hold'em hand evaluator in ECMAScript?

What is wanted is a function, say handEval(hand), which, given a
suitable representation of a hand of 7 cards, returns a value that
accurately represents the strength of the hand. That is,
handEval(hand0) > handEval(hand1) iff hand0 beats hand1,
handEval(hand0) == handEval(hand1) iff hand0 and hand1 tie, and
handEval(hand0) < handEval(hand1) iff hand1 beats hand0.

It would be nice, too, if the return value could easily indicate what
kind of hand it is - high card, pair, two pairs, etc, preferably with
further information to break ties within each kind.

And it would be a further bonus if the evaluator could retain most
of its state when only a few cards change from one hand to another,
in order to gain time when looping through all the possible hands
with a given, fixed subset.

The problem has received a lot of attention in other languages, e.g.,
http://www.codingthewheel.com/archives/poker-hand-evaluator-roundup
But the best solutions can hardly be implemented in ECMAScript - a
123 megabyte lookup table is unpractical. On the other hand, Objects
or sparse Arrays should be reasonably fast and space efficient,
so smaller lookup tables could be fine. How fast can one get?

Any ideas?

(NB: this is Texas hold'em, with 7 cards. Naive assumptions from 5 card
poker do not necessarily apply. There may be a flush and a straight,
but no straight flush. Also, there may be both 4 of a kind and 3 of
a kind, etc. What is wanted is the value of the best 5 cards subset.)

Signature

Johannes


Quick links:

 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage




©2010 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.