Open Side Menu Go to the Top
Register
7 Card Hand Evaluators 7 Card Hand Evaluators

04-21-2008 , 06:33 PM
Quote:
Originally Posted by contravariance
I still can't get the correct number of different type of hands. Any help in fixing the following method (it that's where the problem [if there's a problem]) is very welcome :
You can try to download the Java code from here:
http://pokerai.org/pf3/viewtopic.php?f=3&t=16
it compiles and behaves properly.
Regards ...
7 Card Hand Evaluators Quote
04-21-2008 , 06:34 PM
re-replying to myself, sorry for hi-jacking the thread but this may interest some people... I got it working.

I'm pretty sure the .jar file http://www.stevebrecher.com/misc/TestEvaluators.jar pointed here in this thread contains a bug in the TableEvalLooper.java source file, for the exhaustive test (trying C(52,7) possible combinations).

The loops should be changed to this I think (but then it only works for a single thread with this quick fix [easy to change for multi-thread if needed]) :

Code:
for (int c0 = 52; c0 > 6; c0--) {
                int u0 = table[53+c0];
                for (int c1 = c0-1; c1 > 5; c1--) {
                    int u1 = table[u0+c1];
                    for (int c2 = c1-1; c2 > 4; c2--) {
                        int u2 = table[u1+c2];
                        for (int c3 = c2-1; c3 > 3; c3--) {
                            int u3 = table[u2+c3];
                            for (int c4 = c3-1; c4 > 2; c4--) {
                                int u4 = table[u3+c4];
                                for (int c5 = c4-1; c5 > 1; c5--) {
                                    int u5 = table[u4+c5];
                                    for (int c6 = c5-1; c6 > 0; c6--) {
                                        handTypeSum[table[u5+c6] >> 24]++;
                                        count++;
                                    }
                                }
                            }
                        }
                    }
                }
            }
Which now gives the same results as the other test (and as the other results in this thread) :

Lookup/ENUMERATE
High Card = 23294460
Pair = 58627800
Two Pair = 31433400
Three of a Kind = 6461620
Straight = 6180020
Flush = 4047644
Full House = 3473184
Four of a Kind = 224848
Straight Flush = 41584
Total Hands = 133784560

seconds = 1.2646

In addition to that I'm pretty sure that the method getCount() must be fixed to work correctly when working with multiple threads (it's not because the current version may be working on some setups that it will work as is, i.e. without proper synchronization, on different JVMs / architectures).

Thanks again to Steve and all the others for the wonderful algorithm(s), source code, package, etc.
7 Card Hand Evaluators Quote
04-21-2008 , 06:38 PM
Quote:
Originally Posted by Adrian20XX
You can try to download the Java code from here:
http://pokerai.org/pf3/viewtopic.php?f=3&t=16
it compiles and behaves properly.
Regards ...
Thanks a lot, cool link, more stuff to play with
7 Card Hand Evaluators Quote
04-22-2008 , 03:49 AM
Quote:
Originally Posted by brian64
Is there anyone who could provide help with an Omaha High-Low-Split hand evaluator? The low part seems pretty easy, so even just an Omaha High evaluator would be great.
For an Omaha High evaluator then one simple solution is just to run the evaluator on each of the six 2-card match-ups (ie: 1+2, 1+3, 1+4, 2+3, 2+4 and 3+4) and select the highest evaluation.

Juk
7 Card Hand Evaluators Quote
04-22-2008 , 04:41 AM
Quote:
Originally Posted by jukofyork
For an Omaha High evaluator then one simple solution is just to run the evaluator on each of the six 2-card match-ups (ie: 1+2, 1+3, 1+4, 2+3, 2+4 and 3+4) and select the highest evaluation.

Juk
Isn't it 60 hands for each player that you have to evaluate this way?
C(5;3)*C(4;2)=60
Regards ...
7 Card Hand Evaluators Quote
04-22-2008 , 05:05 AM
Quote:
Originally Posted by Adrian20XX
Isn't it 60 hands for each player that you have to evaluate this way?
C(5;3)*C(4;2)=60
Regards ...
Yep, but for Holdem you still have the C(5,3) part to do and if you are using a (the) 7-card evaluator then you'll just be passing in 6 [ie: C(4,2)] sets of possible hole cards added to the 5 board cards (disclaimer: I just woke up so may not be thinking clearly though... lol).

EDIT: Oh, I forgot in Omaha you have to use two of your own cards, so the 7-card evaluator isn't gonna work and you are correct... Meh to Omaha

Juk
7 Card Hand Evaluators Quote
04-22-2008 , 10:09 AM
Quote:
Originally Posted by brian64
Is there anyone who could provide help with an Omaha High-Low-Split hand evaluator? The low part seems pretty easy, so even just an Omaha High evaluator would be great.
poker-eval has a O8 evaluator. I have played with it a little via the python bindings and it seems to work.
7 Card Hand Evaluators Quote
04-23-2008 , 09:56 AM
Quote:
Originally Posted by Adrian20XX
Isn't it 60 hands for each player that you have to evaluate this way?
C(5;3)*C(4;2)=60
Regards ...
That's certainly the easiest way to do it-- make 60 calls to a 5-card hand evaluator and take the highest ranking hand. I'll probably start with that and then work on optimizations if it's too slow.
7 Card Hand Evaluators Quote
04-23-2008 , 03:28 PM
Actually there was a post regarding Omaha in pokereval a couple of pages back in this thread; it uses the 60*5-card lookup. Going through the thread again, it seems mykey's method could be modified to make a 10*7-card lookup, and this should be much faster than 60*5-cards.
7 Card Hand Evaluators Quote
05-17-2008 , 03:08 PM
Hi,

I've downloaded the various Java evaluators, but it seems they "just" compute One Pair/Two Pairs/Three of A kind/etc. Is there a more precise evaluator? One that could give you "One Pair, Kings" instead of only "One Pair", for example ?

btw, thanks Dave
7 Card Hand Evaluators Quote
05-17-2008 , 07:16 PM
Quote:
Originally Posted by tonypkr7
Hi,

I've downloaded the various Java evaluators, but it seems they "just" compute One Pair/Two Pairs/Three of A kind/etc. Is there a more precise evaluator? One that could give you "One Pair, Kings" instead of only "One Pair", for example ?

btw, thanks Dave
You can easily retrieve the hand from the hand value when you use Steve Brecher's code, check this part that at the C code is in HandEval.h:

Code:
enum {NO_PAIR, PAIR, TWO_PAIR, THREE_OF_A_KIND,
        STRAIGHT, FLUSH, FULL_HOUSE, FOUR_OF_A_KIND, STRAIGHT_FLUSH};

typedef unsigned long Eval_T; /*  Evaluation result in 32 bits = 0VTBMMMM
	/*
	 * Different functions are called for high and for lowball evaluation.  The
	 * result format below is the same except:  For lowball evaluation, as for
	 * wheels in high evaluation, Ace is rank 1 and its mask bit is the LS bit;
	 * otherwise Ace is rank 14, mask bit 0x1000, and the deuce's mask bit is
     * the LS bit.
	 *
	 * For normal evaulation if results R1 > R2, hand 1 beats hand 2;
	 * for lowball evaluation if results R1 > R2, hand 2 beats hand 1.
	 *
	 * Evaluation result in 32 bits = 0x0VTBKKKK:
	 * 
	 * V nybble = value code (NO_PAIR..STRAIGHT_FLUSH)
	 * T nybble = rank (2..14) of top pair for two pair, 0 otherwise
	 * B nybble = rank (1..14) of trips (including full house trips) or quads,
	 *  			or rank of high card (5..14) in straight or straight flush,
	 *              or rank of bottom pair for two pair (hence the symbol "B"),
	 *              or rank of pair for one pair,
	 *              or 0 otherwise
	 * KKKK mask = 16-bit mask with...
	 *              5 bits set for no pair or (non-straight-)flush
	 *              3 bits set for kickers with pair,
	 */
#if d_flop_game
	/*
	 *              2 bits set for kickers with trips,
	 *              1 bit set for pair with full house or kicker with quads
   */
#endif
	/*				1 bit set for kicker with two pair
	 *              or 0 otherwise
	 */
I think other evaluators uses Cactus Kev's representation, even if you can retrieve the hand from the hand value I've seen no code ready to use in order to do this.

Regards ...
7 Card Hand Evaluators Quote
05-18-2008 , 07:48 AM
Hum yes I guess I can work something out from this. After seeing all the codes I thought that Steve Brecher's was the most easy to use anyway
7 Card Hand Evaluators Quote
05-10-2009 , 10:06 AM
2 years later and thousands of posts later...

This thread was amazing, someone recently reminded me off it so I dug it up and gave it a read. Just wondering out of curiosity what has gone on in this area since? Anyway managed to lay a prooven smack down yet?
7 Card Hand Evaluators Quote
05-25-2009 , 07:30 PM
is there a way to get equity vs. a given range or at least equity for 2 opponents with known pocket cards?
7 Card Hand Evaluators Quote
07-09-2014 , 03:22 PM
Crossposting from Poker Theory:

Quote:
Originally Posted by plexiq
Thought i'd share a small 7-card hand evaluator i wrote recently. Nothing too fancy, but it's pretty slim and doesn't have any external dependencies. I think it's somewhat similar to the Senzee7 evaluator but uses a smaller lookup table.

The current version uses a LUT of 64MB (2^25 shorts), and requires one lookup per evaluation. There is a benchmarking class included in the .jar, i am getting around 250m evals/sec for enumerations and 80m/sec for random evaluations.

Java .jar including the source:
http://www.holdemresources.net/misc/handeval/

The relevant indexing code is rather short:
Code:
long low25 = 0x1FFFFFFl;
long quads = 0x4444444444444l;
long ranks = 0x1111111111111l;

//Calculates the 25bit index to the LUT
int calculateIndex(long cards) {
        //r keeps track of the ranks, omitting suits
	long t, r = 0; 
	for (int i = 0; i < 4; i++) {
		t = cards >> i & ranks;
		if (Long.bitCount(t) >= 5) //flush
			return (int) (~(t | t >> 26) & low25);
		else
			r += t;
	}
	
	t = r & quads;
	if (t != 0) { //quads
		t = t >> 1 | ((r | r >> 1) & ranks);
		return (int) (~(t | t >> 26) & low25);
	} else { //other
		return (int) ((r | r >> 26) & low25);
	}
}
The cards parameter uses the lowest 52bits to represent the hand:
bits 0-3: 2s2h2d2c
bits 4-7: 3s3h3d3c
etc.

I am quite sure that the table size can still be reduced, would be great if someone cares to post ideas/improvements.
http://forumserver.twoplustwo.com/15...uator-1457962/
7 Card Hand Evaluators Quote
07-14-2014 , 07:02 AM
Sorry I'm posting on this old thread, but I am doing some theoretical Analysis on Texas Hold'em and was told this Thread would help me... thus I try to understand it in full length. Here I found a fault (it was posted quite some time ago but I did not find any corrections to it later on)

Quote:
Originally Posted by _D&L_
Pretend we have two players that play only two hands:
AK or AA.

First player: AK - 16 combos, AA 6 combos, total 22
First Players chance of playing AK is 16/22
First Players chance of playing AA is 6/22
In my opinion, this is wrong.
If we just play with Aces and Kings, it would be 2 out of 8 cards, thus 8!/6!/2!=8*7/2=28 (and not 22).

First Players chance is 16/28 for AK and 6/28 for AA, plus 6/28 for KK which you left out.

Quote:
Originally Posted by _D&L_
Now assign the second player:

If player 1 was assigned AK (p = 16/22), then
Player 2: (Baysian updating)
Plays AK with 9/12 probability
Plays AA with 3/12 probability
If player 1 was assigned AA (p = 6/22), then
Player 2: (Baysian updating)
Plays AK with 8/9 probability
Plays AA with 1/9 probability

Now what is Player 2's chance of playing AA
(16/22)*(3/12) + (6/22)*(1/9) = 7/33

Now the problem: Player 1 and Player 2 had the same distributions. But 7/33 != 6/22.
If two cards are out, the remaining combinations are 6!/4!/2!=6*5/2=15 (and not 12)
If player 1 got AK, player 2 can get AK with 9/15, AA with 3/15 and KK with 3/15.
If player 1 got AA, player 2 can get AK with 8/15, AA with 1/15 and KK with 6/15.
If player 1 got KK, player 2 can get AK with 8/15, AA with 6/15 and KK with 1/15.

Thus player 2 has the chance of 16/28*3/15 + 6/28*1/15 + 6/28*6/15 = 90/(28*15) = 6/28 (which is pretty much the same chance as player 1 had)


Quote:
Originally Posted by _D&L_
A correct algorithm, would at the very least, have to give both players (with equal distributions) an equal chance of getting AA.
Yes. And if you do your math right even your example would have been correct
7 Card Hand Evaluators Quote
07-14-2014 , 07:11 AM
@_dave_:
Thanks for the crosspost, i didn't realize there was a thread for this in the software forum.

I made some changes to reduce the LUT size. The latest version uses a 8MB table, which improves the performance for random evaluations to about 150m/sec on a 3.4GHz CPU.
7 Card Hand Evaluators Quote
10-20-2014 , 05:45 PM
Sorry to post on this old thread, but I'm trying to build the 2+2 evaluator from XPokerEval in Visual Studio and I'm having some trouble. It doesn't work with <sys/time.h>, I tried to ditch this and use winsock2.h because google told me it handles time functions for windows, but that is generating a lot of errors too.

Can anyone help me build this in visual studio? Or let me know how to do it on cygwin if I have all of the XPokerEval source downloaded?

Thanks
7 Card Hand Evaluators Quote
10-20-2014 , 10:14 PM
Quote:
Originally Posted by nomoD
Sorry to post on this old thread, but I'm trying to build the 2+2 evaluator from XPokerEval in Visual Studio and I'm having some trouble. It doesn't work with <sys/time.h>, I tried to ditch this and use winsock2.h because google told me it handles time functions for windows, but that is generating a lot of errors too.

Can anyone help me build this in visual studio? Or let me know how to do it on cygwin if I have all of the XPokerEval source downloaded?

Thanks
I was able to get it to build, but i had to change some things around. The generate_table.cpp file has two #include "../util/Timer.h" lines, I changed one to #include "../util/Timer.cpp". Also, I just commented out the #include <sys/time.h>.

I also had to change the _tmain functions to main functions. That was enough to get it to build on my laptop in vs2005.

To get it to compile in vs2013, I also had to resolve some linker problems related to the #include "../XPokerEval.CactusKev.PerfectHash/poker.h" line. I ended up changing it to #include "../XPokerEval.CactusKev.PerfectHash/pokerlib.cpp" and I commented out the MTRand53 variable and the function that used it.
After all of this, it did compile in VS2013.

Probably not the best way to do it because I'm no expert, but maybe this will help any other amateurs trying to build this project.
7 Card Hand Evaluators Quote
11-08-2014 , 08:39 PM
Quote:
Originally Posted by Stormcastle
Sorry I'm posting on this old thread, but I am doing some theoretical Analysis on Texas Hold'em and was told this Thread would help me... thus I try to understand it in full length. Here I found a fault (it was posted quite some time ago but I did not find any corrections to it later on)



In my opinion, this is wrong.
If we just play with Aces and Kings, it would be 2 out of 8 cards, thus 8!/6!/2!=8*7/2=28 (and not 22).

First Players chance is 16/28 for AK and 6/28 for AA, plus 6/28 for KK which you left out.



If two cards are out, the remaining combinations are 6!/4!/2!=6*5/2=15 (and not 12)
If player 1 got AK, player 2 can get AK with 9/15, AA with 3/15 and KK with 3/15.
If player 1 got AA, player 2 can get AK with 8/15, AA with 1/15 and KK with 6/15.
If player 1 got KK, player 2 can get AK with 8/15, AA with 6/15 and KK with 1/15.

Thus player 2 has the chance of 16/28*3/15 + 6/28*1/15 + 6/28*6/15 = 90/(28*15) = 6/28 (which is pretty much the same chance as player 1 had)




Yes. And if you do your math right even your example would have been correct
He chose to leave out the KK. and on post #43, I (as mykey1961) corrected his results.

There are 246 possible combinations were both players have either AA or AK.

6 result in AA vs AA
48 result in AA vs AK
48 result in AK vs AA
144 result in AK vs AK

6/246 = 1/41
48/246 = 8/41
144/246 = 24/41

I just popped in to see how the 7 card evaluator has held up over the years.
7 Card Hand Evaluators Quote
01-26-2015 , 01:26 PM
Bump for minor update of #265

I made some changes to reduce the lookup table to 512kb. Would be interested in speed comparisons, as far as i am aware this is the fastest Java evaluator for unordered/sampled evaluations. (Still *much* slower than the 2p2 evaluator for enumerations ldo.)

http://www.holdemresources.net/misc/handeval/
7 Card Hand Evaluators Quote
09-05-2016 , 03:30 PM
linking a new thread in programming forum with some new techniques, guess some may be subscribed here and find it interesting: http://forumserver.twoplustwo.com/19...lator-1621460/
7 Card Hand Evaluators Quote

      
m