View Single Post
  #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