Beispiel #1
0
main()
{
    int deck[52], hand[5], freq[10];
    int a, b, c, d, e, i, j;

    // seed the random number generator
    srand48( getpid() );

    // initialize the deck
    init_deck( deck );

    // zero out the frequency array
    for ( i = 0; i < 10; i++ )
        freq[i] = 0;

    // loop over every possible five-card hand
    for(a=0;a<48;a++)
    {
	hand[0] = deck[a];
	for(b=a+1;b<49;b++)
	{
	    hand[1] = deck[b];
	    for(c=b+1;c<50;c++)
	    {
		hand[2] = deck[c];
		for(d=c+1;d<51;d++)
		{
		    hand[3] = deck[d];
		    for(e=d+1;e<52;e++)
		    {
			hand[4] = deck[e];

			i = eval_5hand( hand );
			j = hand_rank(i);
			freq[j]++;
		    }
		}
	    }
	}
    }

    for(i=1;i<=9;i++)
	printf( "%15s: %8d\n", value_str[i], freq[i] );
}
Beispiel #2
0
int main(void)
{
    int freq[10];
    int a, b, c, d, e, f, g, i, j, k;

    // zero out the frequency array
    for ( i = 0; i < 10; i++ )
        freq[i] = 0;

    // loop over every possible seven-card hand
	for(a=0; a<46; a++)
	{
		for(b=a+1; b<47; b++)
		{
			for(c=b+1; c<48; c++)
			{
				for(d=c+1; d<49; d++)
				{
					for(e=d+1; e<50; e++)
					{
						for(f=e+1; f<51; f++)
						{
							for(g=f+1; g<52; g++)
							{
								i = evaluate_7cards(a, b, c, d, e, f, g);

								j = hand_rank(i);
								freq[j]++;
							}
						}
					}
				}
			}
		}
	}

	for(i=1; i<=9; i++)
		printf( "%15s: %8d\n", value_str[i], freq[i] );

	return 0;
}
int _tmain(int argc, _TCHAR* argv[])
{
	printf("Testing the Senzee7 Hand Evaluator\n");
	printf("----------------------------------\n");

	short int* theTable = create_table("SENZEE7.DAT");
	if (!theTable)
		return -1;
	
	__int64 virginDeck[52];
	for (int c = 0; c < 52; c++)
		virginDeck[c] = (0x1LL << c);

	int freq[9];
	memset(freq, 0, sizeof(freq));

	int c0, c1, c2, c3, c4, c5, c6;
	__int64 h0, h1, h2, h3, h4, h5, h6;
	int count = 0;

	printf("\nEnumerating and evaluating all 133,784,560 million possible 7-card hands...\n\n");

	DWORD dwTime = GetTickCount();

	for (c0 = 0; c0 < 46; c0++) {
		h0 = virginDeck[c0]; // 1st card
		for (c1 = c0+1; c1 < 47; c1++) {
			h1 = h0 | virginDeck[c1]; // 2nd card
			for (c2 = c1+1; c2 < 48; c2++) {
				h2 = h1 | virginDeck[c2]; // 3rd card
				for (c3 = c2+1; c3 < 49; c3++) {
					h3 = h2 | virginDeck[c3]; // 4th card
					for (c4 = c3+1; c4 < 50; c4++) {
						h4 = h3 | virginDeck[c4]; // 5th card
						for (c5 = c4+1; c5 < 51; c5++) {
							h5 = h4 | virginDeck[c5]; // 6th card
							for (c6 = c5+1; c6 < 52; c6++) {
								h6 = h5 | virginDeck[c6]; // 7th card

								freq[9 - hand_rank(theTable[index52c7(h6)])]++;
								// Above line could be re-written as:
								// int hashedIndex = index52c7(h6);
								// int handValue = theTable[hashedIndex];
								// int handCategory = hand_rank(handValue);
								// freq[9 - handCategory]++;

								count++;
							}
						}
					}
				}
			}
		}
	}

	dwTime = GetTickCount() - dwTime;

	printf("High Card:        %d\n", freq[0]);
	printf("One Pair:         %d\n", freq[1]);
	printf("Two Pair:         %d\n", freq[2]);
	printf("Trips:            %d\n", freq[3]);
	printf("Straight:         %d\n", freq[4]);
	printf("Flush:            %d\n", freq[5]);
	printf("Full House:       %d\n", freq[6]);	
	printf("Quads:            %d\n", freq[7]);
	printf("Straight Flush:   %d\n", freq[8]);

	printf("\nEnumerated and evaluated all %d poker hands in %d milliseconds!", count, dwTime);

	std::cin.get();


	return 0;
}
Beispiel #4
0
VALUE HandEval_hand_rank(VALUE self, int val) {
  return INT2NUM(hand_rank(val));
}