Image Image Image




Post new topic Reply to topic  [ 399 posts ]  Go to page Previous  1 ... 16, 17, 18, 19, 20  Next
Author Message
 Post subject: Re: 7-card Poker Hand Evaluators
PostPosted: Mon Mar 08, 2010 2:49 pm 
Offline
Junior member
User avatar

Posts: 39
Favourite Bot: none
Hi

Now I understand why my code doesn't work on handIndex5... It actually compressed even more because there are situations where two suits can make flush and those situations we need only 4-pointers segment. This is because 13-pointer indexes are already there and can be found if we convert non flush suit to nosuit.

One thing I couldn't understand is why handIndex6 get different result with my and bluegaspode code. I couldn't find error from either. Only option is that we have too many keys in that level similar to handRanks7 where we already found unused keys. Another thing that indicates same thing is that bluegaspode's compression is little smaller than keys*4+keys*13.


Top
 Profile E-mail  
 
 Post subject: Re: 7-card Poker Hand Evaluators
PostPosted: Mon Mar 08, 2010 5:07 pm 
Offline
Junior member
User avatar

Posts: 39
Favourite Bot: none
Hi

I got new compression idea. If we trade some space to calculations, like we do in current 2step mode. We can modify result of handIndex5 so it contain 2 parts, first address and then flush color so those can be decoded like:
Code:
address6 = result5 >>> 3; // this gets address shifting
flushsuit = result5 & 7; // this get flush suit 0,1,2,3 or 4 if we don't have possible flush

Now we need only 13-pointer blocks for last 2 levels. Like
Code:
result6 = handIndex6[address6 + card6/13 + ((card6%13 == flushsuit)? 13 : 0)]
rank = handRank7[result6 + card7/13 + ((card67%13 == flushsuit)? 13 : 0)]

This is possible because we can arrange 13-pointer blocks in a way where non flush block is first and then we have flush block. If this is made we don't even need all 13-pointer blocks, because all suits are equal. As result handIndex6 contains only 53365 blocks that makes 2.65MB and handRanks7 contains 82868 blocks that makes 4.11MB.

Unfortunately I probably don't have time to code anything before weekend, but then I make concrete implementation :-)


Top
 Profile E-mail  
 
 Post subject: Re: 7-card Poker Hand Evaluators
PostPosted: Mon Mar 08, 2010 7:23 pm 
Offline
Senior member
User avatar

Posts: 172
Favourite Bot: don't know
I get the impression we get very near to Klaatus algorithm who removed all suits from the lookup tables (and does extra lookups for flushes).
Anyway - if the result is still faster, because some shifts are better than counting the suits - good :)

Hope noone starts saying "nah - who cares about 112MB of Heap these days for RayW".
I think I'll spend some time now with writing a bot again :)
But interesting discussion - like the old C64-days you spent for performance/memory-tuning :)


Top
 Profile E-mail  
 
 Post subject: Re: 7-card Poker Hand Evaluators
PostPosted: Tue Mar 09, 2010 12:09 am 
Offline
Senior member
User avatar

Posts: 458
Location: Now in the mighty PolarBoar variant!
Favourite Bot: ...
Regarding the benchmarks:

For what it's worth - for my applications (random lookups in monte carlo algorithm), Timmy's PSim evaluator is faster than the evaluator that is currently ranked as 1st - the pokerai.game.eval.spears package.


Top
 Profile  
 
 Post subject: Re: 7-card Poker Hand Evaluators
PostPosted: Tue Mar 09, 2010 9:46 am 
Offline
Junior member
User avatar

Posts: 39
Favourite Bot: none
Hi
PolarBear wrote:
Regarding the benchmarks:

For what it's worth - for my applications (random lookups in monte carlo algorithm), Timmy's PSim evaluator is faster than the evaluator that is currently ranked as 1st - the pokerai.game.eval.spears package.

For your application (or any other that needs random hand evaluations) enumeration test doesn't show real result... I try to write random hand tests for all evaluators in next weekend :-) Unfortunately even with enumeration and random hand test we are not complete fair, because many real situations contains part of both. But anyway we get better picture.


Top
 Profile E-mail  
 
 Post subject: Re: 7-card Poker Hand Evaluators
PostPosted: Tue Mar 09, 2010 10:20 am 
Offline
Junior member
User avatar

Posts: 39
Favourite Bot: none
Hi
bluegaspode wrote:
I get the impression we get very near to Klaatus algorithm who removed all suits from the lookup tables (and does extra lookups for flushes).
Anyway - if the result is still faster, because some shifts are better than counting the suits - good :)

Actually we don't remove suits just information what exact suit can form flush. Blurring that information can even help in certain situations. Example in situations where we try to calculate EV for for certain hands, because we can more easily reuse parts of enumeration without enumerating it again.
bluegaspode wrote:
Hope noone starts saying "nah - who cares about 112MB of Heap these days for RayW".

Surely someone thinks about that. Here is kind of joke for those (I made it some time ago to test how fast certain operations are). It uses 255MB of memory, but result is impressive :-)
Code:
Fast Enumerating Evaluator
--- Million hands per second: [b]451,111561[/b], hands 133784560, checksum 264377938088, total time(s): 0.296566463

Current version uses Klaatu FastEval for initialization, but it is very easy to change to any other evaluator :-)


Attachments:
File comment: Fast Enumerating evaluator (joke)
FastEnumeratingEvaluator.zip [1.21 KB]
Downloaded 144 times
Top
 Profile E-mail  
 
 Post subject: Re: 7-card Poker Hand Evaluators
PostPosted: Fri Mar 12, 2010 9:37 pm 
Offline
Junior member
User avatar

Posts: 39
Favourite Bot: none
Hi

Here are results of random hand test. Test generates 20 million random hands and then evaluate those in all hand evaluators. Results below are from second run. I selected it because from some reason Klaatu FastEval gets weird results in first run.

java -cp .;meerkat-api.jar -server pokerai.game.eval.tests.RandomPerformanceTest
Code:
( 1) Indiana-1, 2006, http://pokerai.org/pf3
--- Million random hands per second: [b]0,972621[/b], hands 20000000, checksum 55376705193800, total time(s): 20.562992294

( 2) Indiana-3, 2007, http://pokerai.org/pf3
--- Million random hands per second: [b]1,247427[/b], hands 20000000, checksum 55376705193800, total time(s): 16.033005801

( 3) University of Alberta, 2000, http://spaz.ca/poker
--- Million random hands per second: [b]0,961399[/b], hands 20000000, checksum 13108252184980, total time(s): 20.80301847

( 4) Spears port of Kevin Suffecool's C evaluator, http://pokerai.org/pf3
--- Million random hands per second: [b]0,865359[/b], hands 20000000, checksum 81956185780, total time(s): 23.111803106

( 5) Spears port of 2+2 evaluator, http://pokerai.org/pf3, http://forumserver.twoplustwo.com
--- Million random hands per second: [b]3,180923[/b], hands 20000000, checksum 67385432280, total time(s): 6.287483186

( 6) Steve Brecher HandEval, http://www.stevebrecher.com/Software/software.html
--- Million random hands per second: [b]16,494839[/b], hands 20000000, checksum 583182463888380, total time(s): 1.212500472

( 7) Spears adaptation of RayW LUT hand evaluator, http://pokerai.org/pf3, http://forumserver.twoplustwo.com
--- Million random hands per second: [b]6,115313[/b], hands 20000000, checksum 228743611740, total time(s): 3.270478301

( 9) Pokerstove (Andrew Prock's) jpoker, http://www.pokerstove.com/download/jpoker.tar.gz
--- Million random hands per second: [b]4,011819[/b], hands 20000000, checksum 637752749080940, total time(s): 4.985269357

(10) Mykey1961 algorithm java implementation, http://pokerai.org/pf3
--- Million random hands per second: [b]20,387848[/b], hands 20000000, checksum 67368559293720, total time(s): 0.980976493

(12) Mykey1961 algorithm java implementation (experimental optimization), http://pokerai.org/pf3
--- Million random hands per second: [b]21,443759[/b], hands 20000000, checksum 58414105233120, total time(s): 0.932672309

(14) Klaatu FastEval, http://pokerai.org/pf3
--- Million random hands per second: [b]23,643674[/b], hands 20000000, checksum 39563464280, total time(s): 0.845892215

(16) Hammer Dag evaluator, http://www.pst.ifi.lmu.de/~hammer/poker/handeval.html
--- Million random hands per second: [b]4,339219[/b], hands 20000000, checksum 81854567720, total time(s): 4.609124553

(18) Supersonic's evaluator, http://pokerai.org/pf3/viewtopic.php?p=15760#p15760
--- Million random hands per second: [b]2,691254[/b], hands 20000000, checksum 228743611740, total time(s): 7.431480118

(19) Jokipii's compressed RayW LUT Evaluator, http://pokerai.org/pf3/
--- Million random hands per second: [b]4,849002[/b], hands 20000000, checksum 228783457780, total time(s): 4.124560245


Zip also contains new compression mode for LUT, what I proposed earlier this week. Now smallest version of jhandranks.ser is only 17.4MB. New mode gets also good results from enumeration test. Enumeration results below:
Code:
(19) Jokipii's compressed LUT Evaluator, http://pokerai.org/pf3/
--- Million hands per second: [b]166,727876[/b], hands 133784560, checksum 3026689691549, total time(s): 0.802412667


Attachments:
File comment: New version of evaluator test package including Random hand evaluation test, etc...
pokerai.zip [668.29 KB]
Downloaded 232 times
Top
 Profile E-mail  
 
 Post subject: Re: 7-card Poker Hand Evaluators
PostPosted: Fri Mar 12, 2010 10:39 pm 
Offline
Senior member
User avatar

Posts: 172
Favourite Bot: don't know
congratulations !

jokipii, why didn't you provide the test preconfigured to use the smalles LUT ?
I tried MODE_COMPRESS | MODE_2STEP |MODE_SPLIT but the resulting jHandranks are 30MB.

Also the master 'PerformanceTest2' then doesn't work of course.


Top
 Profile E-mail  
 
 Post subject: Re: 7-card Poker Hand Evaluators
PostPosted: Fri Mar 12, 2010 11:49 pm 
Offline
Junior member
User avatar

Posts: 39
Favourite Bot: none
Hi

bluegaspode wrote:
congratulations !

jokipii, why didn't you provide the test preconfigured to use the smalles LUT ?
I tried MODE_COMPRESS | MODE_2STEP |MODE_SPLIT but the resulting jHandranks are 30MB.

Also the master 'PerformanceTest2' then doesn't work of course.


To test that use "java -server pokerai.game.eval.jokipii.Test" it contains nosuit() method that runs performance and validity tests for smallest LUT. Mode is LUTEvaluator.MODE_COMPRESS | LUTEvaluator.MODE_SPLIT | LUTEvaluator.MODE_NOSUIT_COMPRESS.


Top
 Profile E-mail  
 
 Post subject: Re: 7-card Poker Hand Evaluators
PostPosted: Sat Mar 13, 2010 12:52 pm 
Offline
Junior member
User avatar

Posts: 39
Favourite Bot: none
Hi

Here is some graphics how different modes affect on LUT size and relative enumeration speed. All values in chart are relative to largest one. There are two sizes for LUTs that can be done without 5 and 6 card hand tables. "Size % (only 7)" is size where LUT is generated whitout 5 and 6 card hand evaluations and "Size % all" is LUT that can evaluate also those hands. "1st run %" shows relative speed when jvm is just started. "10th run %" shows relative speed after jvm made optimizations.

Latest nosuit mode speed is amazing, because that mode usage contains 14 additional calculations and one additional table look up. I think that results indicate possibility to make faster LUTs by reorganizing state order. Another indicator is relative speed of compressed tables vs uncompressed, because they are used exactly same way and they contain exactly same states. Only difference between those is how states are organized.

Ideally better order of states makes less cache misses and therefore look ups are faster. This is because main memory access is actually very time consuming operation. Actually idea can be tested without any changes by using jvm option -XX:+UseLargePages. Unfortunately I have lousy windows Vista home version that do not support needed policy settings, or at least there are no tools to change those and I couldn't find registry keys and values that are used. If someone with better operating system can test that option with original and/or compressed LUT and send results (with and without flag) here it will help a lot.

Currently I think that best order contains some kind of clusters of states where each cluster is size of cache page and as many as possible sequential table look ups hits same cluster. Anyway I need little more thinking to find how states should be ordered.


Attachments:
modes.png
modes.png [ 25.49 KB | Viewed 2947 times ]
File comment: OpenOffice Calc containing graph data
modes.ods [27.28 KB]
Downloaded 64 times
Top
 Profile E-mail  
 
 Post subject: Re: 7-card Poker Hand Evaluators
PostPosted: Sat Mar 13, 2010 2:23 pm 
Offline
Senior member
User avatar

Posts: 172
Favourite Bot: don't know
jokipii wrote:
Currently I think that best order contains some kind of clusters of states where each cluster is size of cache page and as many as possible sequential table look ups hits same cluster. Anyway I need little more thinking to find how states should be ordered.

As as start, would it make sense to create a histogram of how often each block is referenced and just reorder by it ?
Then most accessed blocks will be together and the chance is high that there are on the same page ?

Also does it make sense, to focus more on specific compression modes ?
Looking at your graph NoSuitSplit beats all previous solutions in speed and size (except original+split, which are not competitive due to their sizes) so one should focus on this ?


Top
 Profile E-mail  
 
 Post subject: Re: 7-card Poker Hand Evaluators
PostPosted: Sat Mar 13, 2010 10:22 pm 
Offline
Senior member
User avatar

Posts: 172
Favourite Bot: don't know
bluegaspode wrote:
jokipii wrote:
As as start, would it make sense to create a histogram of how often each block is referenced and just reorder by it ?

To answer myself - no it doesn't make sense. There are just 214 (of 81.000) blocks which are referenced >100 times.
So the probability that just by reordering this simple way we get better chunks of memory are nil.


Top
 Profile E-mail  
 
 Post subject: Re: 7-card Poker Hand Evaluators
PostPosted: Mon Apr 26, 2010 2:35 am 
Offline
New member
User avatar

Posts: 3
Favourite Bot: None
I've posted a summary for a new 7-card evaluator on my blog,

http://specialk-coding.blogspot.com/2010/04/texas-holdem-5-and-7-card-evaluation.html

I don't know the current state of technology. I hope to find the time to give more detail! :sherlok


Top
 Profile E-mail  
 
 Post subject: Re: 7-card Poker Hand Evaluators
PostPosted: Mon Apr 26, 2010 6:03 pm 
Offline
Senior member
User avatar

Posts: 172
Favourite Bot: don't know
So how is the lookup table built ?


Top
 Profile E-mail  
 
 Post subject: Re: 7-card Poker Hand Evaluators
PostPosted: Mon May 10, 2010 6:17 pm 
Offline
Level1 member
User avatar

Posts: 42
Favourite Bot: ZZ'
how to decode steve brecher return results. Is the suit information available in the resulted cards? Any examples are well come.


Top
 Profile E-mail  
 
 Post subject: Re: 7-card Poker Hand Evaluators
PostPosted: Wed May 12, 2010 12:33 am 
Offline
Junior member
User avatar

Posts: 29
Favourite Bot: Sonia
Hi,

A couple questions. First, is the fastest hand evaluator the one under the folder "spears" or "spears2p2"?

I got the spears2p2 one working, but my results don't seem to be too great:

Loading evaluation tables ...
Evaluation tables loaded in 1.156 seconds
( 5) Spears port of 2+2 evaluator, http://pokerai.org/pf3, http://forumserver.twoplustwo.com
--- Hands per second: 9898236, hands 133784560, checksum 450334402748, total time: 13516

I am running on XP Pro, 3G or RAM, Dual Core Intel T5200 @ 1.6GHz. Am I just lacking CPU power? Or am I running the wrong evaluator?

Thanks for any help,
MS


Top
 Profile  
 
 Post subject: Re: 7-card Poker Hand Evaluators
PostPosted: Wed May 12, 2010 7:45 am 
Offline
Senior member
User avatar

Posts: 172
Favourite Bot: don't know
"( 7) Spears adaptation of RayW LUT hand evaluator, http://pokerai.org/pf3, http://forumserver.twoplustwo.com",

Is the one you are searching for.


Top
 Profile E-mail  
 
 Post subject: Re: 7-card Poker Hand Evaluators
PostPosted: Wed May 12, 2010 7:45 am 
Offline
Senior member
User avatar

Posts: 458
Location: Now in the mighty PolarBoar variant!
Favourite Bot: ...
I'm wondering if PSim is thread safe? Does anyone know?


Top
 Profile  
 
 Post subject: Re: 7-card Poker Hand Evaluators
PostPosted: Wed May 12, 2010 11:36 am 
Offline
Junior member
User avatar

Posts: 29
Favourite Bot: Sonia
bluegaspode wrote:
"( 7) Spears adaptation of RayW LUT hand evaluator, http://pokerai.org/pf3, http://forumserver.twoplustwo.com",

Is the one you are searching for.


Ah thank you, that is much better. Now my machine is getting about 105m hands/sec.

Also, I had to fix an error in the test code. Line 252 should read:

print(sum, time, NT*133784560, 6);

If anyone is maintaining it, or there is different thread for these corrections, please let me know.


Top
 Profile  
 
 Post subject: Re: 7-card Poker Hand Evaluators
PostPosted: Fri May 21, 2010 7:59 am 
Offline
New member
User avatar

Posts: 3
Favourite Bot: None
Hey all,

I've started a new coding blog, but of particular relevance to this thread is perhaps:

http://specialk-coding.blogspot.com/201 ... or_23.html

where the idea is explained. It's a little bit different.

There's also a link to some code hosted on Google Project:

http://code.google.com/p/specialkpokereval/

It's all open source, natch.

To answer an earlier poster, the lookup table is an array. The "key" is found by "adding
up the cards". This key is the index for the rank in the array. The array is 15Mb. The
7-card evaluator is built from a 5-card evaluator which is then released. At the moment
there are two versions, one in Objective-C and the other Java. The Objective-C version
is much more developed and the writing is much better (I have a bias here). Tentatively
it can get through over 33 million randomly generated 7-card hands per second on a
2010 MacBook Pro, whatever that means.

I'm not on this forum very often, have a look at the links above if you're interested. There's
more explanation to be found there. Enjoy.

Best wishes,

K


Top
 Profile E-mail  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 399 posts ]  Go to page Previous  1 ... 16, 17, 18, 19, 20  Next


Who is online

Users browsing this forum: No registered users and 14 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to: