Two Plus Two Newer Archives  

Go Back   Two Plus Two Newer Archives > Internet Gambling > Software
FAQ Community Calendar Today's Posts Search

Reply
 
Thread Tools Display Modes
  #91  
Old 12-29-2006, 11:39 AM
Gullanian Gullanian is offline
Senior Member
 
Join Date: Dec 2006
Posts: 1,748
Default Re: 7 Card Hand Evaluators

Heres a better test for our evaluators:

holeCard1 = 0;
holeCard2 = 1;

for(opCard1 = 0; opCard1 < 52; opCard1++)
{
if(opCard1 == holeCard1 || opCard1 == holeCard2)
continue;

cout<<".";
cout.flush();

for(opCard2 = opCard1 + 1; opCard2 < 52; opCard2++)
{

if(opCard2 == holeCard1 || opCard2 == holeCard2)
continue;

// Loop through all the deck cards
for(c1 = 0; c1 < 52; c1++)
{
if(c1 == holeCard1 || c1 == holeCard2 || c1 == opCard1 || c1 == opCard2)
continue;

for(c2 = c1 + 1; c2 < 52; c2++)
{
if(c2 == holeCard1 || c2 == holeCard2 || c2 == opCard1 || c2 == opCard2)
continue;

for(c3 = c2 + 1; c3 < 52; c3++)
{
if(c3 == holeCard1 || c3 == holeCard2 || c3 == opCard1 || c3 == opCard2)
continue;

for(c4 = c3 + 1; c4 < 52; c4++)
{
if(c4 == holeCard1 || c4 == holeCard2 || c4 == opCard1 || c4 == opCard2)
continue;

for(c5 = c4 + 1; c5 < 52; c5++)
{
if(c5 == holeCard1 || c5 == holeCard2 || c5 == opCard1 || c5 == opCard2)
continue;

WORK OUT OUR HANDS STRENGTH (holeCard1, holeCard2, C1...C5)
WORK OUT OPPONENTS HANDS STRENGTH (opCard1, opCard2, C1...C5)

// Increment totals counters
if(ourHandStrength < oppHandStrength)
totalWins++;
else if (ourHandStrength > oppHandStrength)
totalLosses++;
else
totalDraws++;
}}}}}}}

cout<<endl<<endl<<"Wins : "<<totalWins<<" ("<<((float)totalWins/2097572400)*100<<"%)"<<endl;
cout<<"Draws : "<<totalDraws<<" ("<<((float)totalDraws/2097572400)*100<<"%)"<<endl;
cout<<"Losses : "<<totalLosses<<" ("<<((float)totalLosses/2097572400)*100<<"%)"<<endl<<end l;
cout<<"Total Combinations : "<<totalWins + totalDraws + totalLosses<<endl;
cout<<"Time MS : "<<(endTime-startTime)<<endl;
cout<<"Time Secs : "<<(endTime-startTime)/1000<<endl;
cout<<"Time Mins : "<<((endTime-startTime)/1000)/60<<endl;
cout<<"Iters per second : "<<(2097572400/(endTime-startTime))*1000<<endl<<endl;

My evaluator can run through the 2.1 billion games in 2 minutes. Pretty fast in my opinion, but from the numbers other people are getting im sure it can be beaten flat on it's face!
Reply With Quote
  #92  
Old 12-29-2006, 12:50 PM
Steve Brecher Steve Brecher is offline
Member
 
Join Date: Sep 2004
Posts: 45
Default Re: 7 Card Hand Evaluators

[ QUOTE ]
Heres a better test for our evaluators:

[/ QUOTE ]
(For a constant pair of hole cards, evaluate all combos of one opponent and board). Why is this better? Also, while it won't make a significant difference, one might as well avoid unnecessary loop executions and conditions (untested modification):
<font class="small">Code:</font><hr /><pre>
holeCard1 = 0;
holeCard2 = 1;

for(opCard1 = holeCard2 + 1; opCard1 &lt; 51; opCard1++)
{

cout&lt;&lt;".";
cout.flush();

for(opCard2 = opCard1 + 1; opCard2 &lt; 52; opCard2++)
{

// Loop through all the deck cards &gt; holecard2
for(c1 = holeCard2 + 1; c1 &lt; 48; c1++)
{
if(c1 == opCard1 || c1 == opCard2)
continue;

for(c2 = c1 + 1; c2 &lt; 49; c2++)
{
if(c2 == opCard1 || c2 == opCard2)
continue;

for(c3 = c2 + 1; c3 &lt; 50; c3++)
{
if(c3 == opCard1 || c3 == opCard2)
continue;

for(c4 = c3 + 1; c4 &lt; 51; c4++)
{
if(c4 == opCard1 || c4 == opCard2)
continue;

for(c5 = c4 + 1; c5 &lt; 52; c5++)
{
if(c5 == opCard1 || c5 == opCard2)
continue;

// evaluate and tally here
}}}}}}}</pre><hr />
Reply With Quote
  #93  
Old 12-29-2006, 01:19 PM
Gullanian Gullanian is offline
Senior Member
 
Join Date: Dec 2006
Posts: 1,748
Default Re: 7 Card Hand Evaluators

I believe it to be a better test bed because with the other test, the cards are presented ordered already, which means that some sort algorithms by nature will out perform others. In this scenario, the two sets of 7 cards are not always ordered (but partially ordered). I think it's a fairer test.
Reply With Quote
  #94  
Old 12-29-2006, 01:35 PM
mykey1961 mykey1961 is offline
Senior Member
 
Join Date: Oct 2005
Posts: 249
Default Re: 7 Card Hand Evaluators

[ QUOTE ]
Hey mykey question on your evaluator

[ QUOTE ]

Totals[Table[Table[Table[Table[Table[Table[Table[c1+52]+c2]+c3]+c4]+c5]+c6]+c7] shr 20]);

[/ QUOTE ]

not good with C++, but what are you representing hand strength as? a digit between 1 and 9? I notice your counters are highly efficient, because you can just use the hand rank as an index to your array. But to do that, is your hand rank just a number 1 through 9? as opposed to say, defining wich "2 pair" beat another "2 pair." Perhaps i'm just misunderstand, cause I don't know c++

P.s. how fast was your mapped array when incrementing counters, and when not? i think you flipped your times around..reporting a higher time with counters?

At anyrate, i'm 2/3 of the way done making your mapped table array for comparison purposes. Mapping one 4MB array to another takes like trillions of calculations (maybe you had some shortcut)...my computers grinding away.... Only one more array to map.

[/ QUOTE ]


I'm not using the rank as an index.

Think of my 1 big table as broken down into 7 smaller tables.

I start at state 0, where I have no knowledge about the cards to be ranked.

When I get my first card to be ranked, I use my current state, and the 1st card as a vector to my new state.

State_1 = Table0[State_0,Card_1]
State_2 = Table1[State_1,Card_2]
State_3 = Table2[State_2,Card_3]
State_4 = Table3[State_3,Card_4]
State_5 = Table4[State_4,Card_5]
State_6 = Table5[State_5,Card_6]

This last step is a little different

Rank = Table6[State_6,Card_7]


The values in Table6 are not states like in Table0 thru Table5, they are actual rankings.

My ranking is a 24 bit value. it's best viewed in Hex format.

If my 7 cards are

AcQh3c8hTcTd5d = 0x2AEC80

A = Ten
B = Jack
C = Queen
D = King
E = Ace

6s5s4h3sJs2dTc = 0x465432
Reply With Quote
  #95  
Old 12-29-2006, 01:41 PM
mykey1961 mykey1961 is offline
Senior Member
 
Join Date: Oct 2005
Posts: 249
Default Re: 7 Card Hand Evaluators

[ QUOTE ]
[ QUOTE ]
Heres a better test for our evaluators:

[/ QUOTE ]
(For a constant pair of hole cards, evaluate all combos of one opponent and board). Why is this better? Also, while it won't make a significant difference, one might as well avoid unnecessary loop executions and conditions (untested modification):
<font class="small">Code:</font><hr /><pre>
holeCard1 = 0;
holeCard2 = 1;

for(opCard1 = holeCard2 + 1; opCard1 &lt; 51; opCard1++)
{

cout&lt;&lt;".";
cout.flush();

for(opCard2 = opCard1 + 1; opCard2 &lt; 52; opCard2++)
{

// Loop through all the deck cards &gt; holecard2
for(c1 = holeCard2 + 1; c1 &lt; 48; c1++)
{
if(c1 == opCard1 || c1 == opCard2)
continue;

for(c2 = c1 + 1; c2 &lt; 49; c2++)
{
if(c2 == opCard1 || c2 == opCard2)
continue;

for(c3 = c2 + 1; c3 &lt; 50; c3++)
{
if(c3 == opCard1 || c3 == opCard2)
continue;

for(c4 = c3 + 1; c4 &lt; 51; c4++)
{
if(c4 == opCard1 || c4 == opCard2)
continue;

for(c5 = c4 + 1; c5 &lt; 52; c5++)
{
if(c5 == opCard1 || c5 == opCard2)
continue;

// evaluate and tally here
}}}}}}}</pre><hr />

[/ QUOTE ]

I think the choice of

holeCard1 = 0;
holeCard2 = 1;

was unfortunate.

If it had been

holeCard1 = x;
holeCard2 = y;

where x and y are defines elsewhere then the loop collision checking is required.

even

holeCard1 = 1;
holeCard2 = 10;

would require loop checking.
Reply With Quote
  #96  
Old 12-29-2006, 02:23 PM
Gullanian Gullanian is offline
Senior Member
 
Join Date: Dec 2006
Posts: 1,748
Default Re: 7 Card Hand Evaluators

I just gave the primitive loop as a base to work on, I've just managed to speed mine up a lot by creating arrays holding values to loop through, eliminating the need of all the ORs.
Reply With Quote
  #97  
Old 12-29-2006, 02:59 PM
mykey1961 mykey1961 is offline
Senior Member
 
Join Date: Oct 2005
Posts: 249
Default Re: 7 Card Hand Evaluators

[ QUOTE ]
I just gave the primitive loop as a base to work on, I've just managed to speed mine up a lot by creating arrays holding values to loop through, eliminating the need of all the ORs.

[/ QUOTE ]

I think an updating double linked list of unused cards might allow for faster looping.
Reply With Quote
  #98  
Old 12-29-2006, 03:52 PM
Gullanian Gullanian is offline
Senior Member
 
Join Date: Dec 2006
Posts: 1,748
Default Re: 7 Card Hand Evaluators

I've optimised my code a lot more, it's looping all 2.1 billion games in around 103-106 seconds.
Reply With Quote
  #99  
Old 12-29-2006, 06:17 PM
jukofyork jukofyork is offline
Senior Member
 
Join Date: Sep 2004
Location: Leeds, UK.
Posts: 2,551
Default Re: Which is the best packed/unpacked so far?

[ QUOTE ]
Jukofyork: Thank you for the sorting network idea! Never seen them before, very interesting! It sped my code up from 15million per second to 35 million per second, I think I can squeeze a little more out of it as well!

[/ QUOTE ]
Hey, np and glad it was helpful. I think this is one of the most interesting threads we've ever had running here!

Juk [img]/images/graemlins/smile.gif[/img]
Reply With Quote
  #100  
Old 12-29-2006, 06:25 PM
RayW RayW is offline
Junior Member
 
Join Date: Mar 2005
Posts: 24
Default Re: 7 Card Hand Evaluators

MyKey,

Am I right in saying that your procedure doesn't need a sort for the input cards. If you "train" your array with all the permutations, it would give the correct handrank no matter what order the cards come in (True?).

Another thought is to reduce the size of the array by half by using the 7462 (i.e. unsigned short) possible hand ranks (ref cactus key). Most possibilities for one hand rank group (pairs) is 2860 (12 possible pairs + Combin(12,3) for the other 3 cards) for the bottom 12 bits, while using the top 4 bits for the 9 main hand ranks (high card, pairs, 2pair...). A sixty meg array feels twice as good as a 120 meg one. [img]/images/graemlins/wink.gif[/img]

Thank You for the interesting posts, I am definitely watching with interest.

Thank You,
Ray
Reply With Quote
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 09:12 PM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2026, vBulletin Solutions Inc.