Actionscript 3 poker hand evaluator

This Actionscript Flash poker (5-card & Texas Hold’em) evaluator will evaluate more than 14,000 hands per second, with a size of around 6 kb. It also includes classes to wrap everything up nice and tight for convenience.

Starting from this post about poker hand evaluators, i converted the improved version of Cactukev’s poker hand evaluator to AS3 some time ago, and wrapped it in some nice OO classes to make it easily accessible.

The OO classes include ways to handle a Deck of cards, a Dealer to draw cards from it, objects to represent a 5- and 7-card hand and compare strengths, and a Card class to make card strength and textual representation easy.

The straight dope is that I have tested it to evaluate approx. 2.6 mio. 5-card poker hands in 6.3 seconds, and 133 mio. 7-card poker hands in approx. 2.5 hours, or about 14.000 hands per second. The test evaluated the correct evaluation of all possible 5- and 7-card poker hands.
The tests were run on a 2.8 gHz Macbook Pro with 4Gb RAM

The .swc binary can be found here

API reference here

The test to evaluate that it runs correctly here (AIR application)

And the source code here

License:
The original code i ported it from was released to the public domain, and is as such free to use, modify and redistribute.
I am releasing this code under the MIT license. License info is found in the source files.

Update:

Here is the original CactusKev hand evaluator source code:

4 thoughts on “Actionscript 3 poker hand evaluator

  1. Luís Fonseca says:

    Hi,

    Thanks for this!

    Do you have any idea on how to after knowing hand is the strongest, extract the winning cards?

    Thanks in advance,
    Luís Fonseca

    • Houen says:

      On a 5-card hand, you just use the AHand.getCard(numcard) method (numcard 0-5). For a 7-card hand, no, sorry. The backwards method of doing it would be to extract the 7 cards, and then creating the 7! possible hands and comparing their strengths (which is basically what the evaluator for 7-card hands does) and then extracting the cards of the stringest 5-card hand

  2. Nir says:

    Hey, I have been trying to import the project and the swc with no success.
    Could you publish instructions on how to test this project?

  3. Nir says:

    Hey, I’m having trouble to test this code as a project.
    Could you publish instructions how to operate and test the project? I would realy appreciate it :)

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code class="" title="" data-url=""> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> <pre class="" title="" data-url=""> <span class="" title="" data-url="">