ChrisE
Joined: Apr 13, 2013
• Threads: 2
• Posts: 32
April 26th, 2013 at 6:10:57 PM permalink
Also, just to make sure I even understand the point of array1... this should have all the ways of making a straight, including the starting hand... meaning it *should* return 8 (four aces, four sixes)

#edit:

No, the correct answer is six, because this is a possible straight flush. That means there's only 6 flushes + 2 straight flushes. So they need to be ordered low to high.
CrystalMath
Joined: May 10, 2011
• Threads: 8
• Posts: 1826
April 26th, 2013 at 7:02:26 PM permalink
Quote: ChrisE

I think I've found where the error may be coming from, but I'm not sure why.

`        Debug.Log(array1[HandIndex4(0, 1, 2, 3)][STRAIGHT]);        Debug.Log(array1[HandIndex4(0, 2, 3, 1)][STRAIGHT]);        Debug.Log(array1[HandIndex4(0, 1, 3, 2)][STRAIGHT]);`

So that's looking in array1 for how many straights there are. It should be the same for each because they are all suited 2, 3, 4, 5 just listed in a different order. Sadly, they're giving me the index numbers: 0, 20821, and 47 with the results of the debugs being:

`608`

This makes zero sense to me, and I have no clue what's going on at this point. Any ideas?

The method for finding a hand index relies on the hand being pre-sorted, so only the first one will point to the hand you are looking for, which is good because it contains the correct number of flushes.
I heart Crystal Math.
ChrisE
Joined: Apr 13, 2013
• Threads: 2
• Posts: 32
April 26th, 2013 at 8:03:22 PM permalink
My hands are not sorted at all. This appears to be my issue. :(
ChrisE
Joined: Apr 13, 2013
• Threads: 2
• Posts: 32
April 26th, 2013 at 10:26:45 PM permalink
Okay, hands all sorted... onto the next issue.

Once you have an array with the best possible outcome after taking all weights into consideration... how do you turn that into the payout percentage?
cherrnp
Joined: May 7, 2013
• Threads: 0
• Posts: 4
May 7th, 2013 at 11:40:54 PM permalink
I'm working on writing a VP expected value code. I'm not sure about these steps. What should say array1 be? It is for holding 1 card. So we want to loop over 4 of the 5 cards something like this...

int HandIndex4(int c1, int c2, int c3, int c4)
{
int r;
r=combin_array[52][4]-combin_array[52-c1][4];
r+=combin_array[51-c1][3]-combin_array[52-c2][3];
r+=combin_array[51-c2][2]-combin_array[52-c3][2];
r+=combin_array[51-c3][1]-combin_array[52-c4][1];
return r;
}

for(int i=0;i<52;i++)
{
for(int j=i+i;j<52;j++)
{
for(int k=j+1;k<52;k++)
{
for(int l=k+1;l<52;l++)
{
//Calculate the index for these four cards

array1[HandIndex(i,j,k,l)][handscore]++;
// How do I get handscore??
// What do I put for the 5th card to fill out the hand

}}}}

Obviously I'm missing something with these arrays. How do I calculate the hand score?

Do I loop over all possible 5th cards? That would lead to looping over 2,598,960 hands to fill the array?

Thanks for any assistance you can provide.

/// from the wizard's page....
For each of the 5 ways to choose 4 out of 5 cards on the deal, translate the four cards into an index number from 0 to 270,724 (I'll explain how to do that later), and increment element [index number][hand score] of array1 by 1.

For each of the 10 ways to choose 3 out of 5 cards on the deal, translate the three cards into an index number from 0 to 22,099, and increment element [index number][hand score] of array2 by 1.

For each of the 10 ways to choose 2 out of 5 cards on the deal, translate the two cards into an index number from 0 to 1,325, and increment element [index number][hand score] of array3 by 1.

For each of the 5 ways to choose 1 out of 5 cards on the deal, translate the card into an index number from 0 to 51, and increment element [index number][hand score] of array4 by 1.

Increment element [hand score] of array5 by 1.
ChrisE
Joined: Apr 13, 2013
• Threads: 2
• Posts: 32
May 7th, 2013 at 11:49:08 PM permalink
I'm still not getting this all, but I think this is what you're supposed to do for array1:
You're going through all hands. Each hand will be 5 cards. You want handIndex4 for each of the 5 ways you can organize those cards.

So you deal all cards as hand[ a ], hand[ b ], hand[ c ], hand[ d ], hand [ e ] (I'm going to write these as a, b, c, d, e for shorthand, but that should be hand[a], hand[e], etc.)

Then you do:

HandIndex4(a, b, c, d);
HandIndex4(a, b, c, e);
HandIndex4(a, b, d, e);
HandIndex4(a, c, d, e);
HandIndex4(b, c, d, e);

This is all five ways to choose 4 out of the 5 cards.

Remember, these have to be ordered to get it correct!
cherrnp
Joined: May 7, 2013
• Threads: 0
• Posts: 4
May 8th, 2013 at 12:14:45 AM permalink
Thats fine for the HandIndex, but what about the hand value? That's the part I don't follow. And then again if you loop over all of them and then do it in the various orders it seems to be redundant. I thought that was the point of the weighting?

Looking at the vpgenius page it looks like you may do it the way you are talking about for the indexing then then use the handscore that you have in the main loop for all 5 cards. Not sure though.

//// from vpgenius
For each of the 5 individual cards, update the total number of hands of type H which include that card (Array #2).
ChrisE
Joined: Apr 13, 2013
• Threads: 2
• Posts: 32
May 8th, 2013 at 12:20:15 AM permalink
The hand value is the value of all five cards. What you're saying is that if you look up a, b, c, d... then a, b, c, d, e is one of the many possibilities of what you can draw (hence you increase a, b, c, d by one to represent drawing a, b, c, d, e.)

You don't do it for the various orders. You always order from smallest to largest.
cherrnp
Joined: May 7, 2013
• Threads: 0
• Posts: 4
May 8th, 2013 at 12:32:28 AM permalink
Giving it a try...will see how it goes. Thanks.
ChrisE
Joined: Apr 13, 2013
• Threads: 2
• Posts: 32
May 8th, 2013 at 12:33:49 AM permalink
Nevermind. :D

• Jump to: