1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131
|
/*
* Copyright (c) 1980 Regents of the University of California.
* All rights reserved. The Berkeley software License Agreement
* specifies the terms and conditions for redistribution.
*/
#ifndef lint
char copyright[] =
"@(#) Copyright (c) 1980 Regents of the University of California.\n\
All rights reserved.\n";
#endif not lint
#ifndef lint
static char sccsid[] = "@(#)test.c 5.1 (Berkeley) 5/30/85";
#endif not lint
#include <stdio.h>
#include "deck.h"
CARD known[ CARDS ]; /* a deck */
CARD deck[ CARDS ]; /* a deck */
CARD hand[ 4 ]; /* a hand */
int knownum;
main( argc, argv )
int argc;
char *argv[];
{
register int k, l, m;
int i, j, is, n, sum, sum2;
CARD ic, jc;
CARD d[ CARDS];
extern char expl[];
printf( "Assuming cards are same suit\n" );
if( argc == 2 ) {
is = atoi( *++argv );
printf( "Starting at i = %d\n", is );
}
makedeck( deck );
# if 0
for( i = is; i < RANKS; i++ ) { /* first card */
ic.rank = i;
ic.suit = 0;
hand[0] = ic;
for( j = 0; j <= i; j++ ) {
printf( "%d %d: sum = %d\n", i, j, -10000000 );
printf( "%d %d: sum2 = %d\n", i, j, -10000000 );
}
for( j = i + 1; j < RANKS; j++ ) { /* second card */
jc.rank = j;
jc.suit = 0;
hand[1] = jc;
for( k = 0; k < CARDS; k++ ) d[k] = deck[k];
n = CARDS;
remove_card( ic, d, n-- );
remove_card( jc, d, n-- );
sum = 0;
sum2 = 0;
for( k = 0; k < n - 1; k++ ) { /* 3rd card */
hand[2] = d[k];
for( l = k + 1; l < n; l++ ) { /* 4th card */
hand[3] = d[l];
for( m = 0; m < n; m++ ) { /* cut card */
if( m != l && m != k )
sum += scorehand(hand, d[m], 4, FALSE, FALSE);
sum2 += scorehand(hand, d[m], 4, TRUE, FALSE);
}
}
}
printf( "%d %d: sum = %d\n", i, j, sum );
printf( "%d %d: sum2 = %d\n", i, j, sum2 );
fflush( stdout );
}
}
printf( "\nthe hand scores %d\n", i );
# else
hand[0].rank = 0;
hand[1].rank = 1;
hand[2].rank = 2;
hand[3].rank = 3;
hand[4].rank = 4;
hand[0].suit = 0;
hand[1].suit = 0;
hand[2].suit = 0;
hand[3].suit = 0;
hand[4].suit = 0;
printf("scorehand of hand = %d\n", scorehand(hand, hand[4], CINHAND, FALSE, TRUE));
printf("\t%s\n", expl);
hand[0].rank = 0;
hand[1].rank = 1;
hand[2].rank = 2;
hand[3].rank = 3;
hand[4].rank = 4;
hand[0].suit = 0;
hand[1].suit = 0;
hand[2].suit = 0;
hand[3].suit = 0;
hand[4].suit = 0;
printf("scorehand of crib = %d\n", scorehand(hand, hand[4], CINHAND, TRUE, TRUE));
printf("\t%s\n", expl);
hand[0].rank = 0;
hand[1].rank = 1;
hand[2].rank = 2;
hand[3].rank = 3;
hand[4].rank = 4;
hand[0].suit = 0;
hand[1].suit = 0;
hand[2].suit = 0;
hand[3].suit = 0;
hand[4].suit = 1;
printf("scorehand of hand = %d\n", scorehand(hand, hand[4], CINHAND, FALSE, TRUE));
printf("\t%s\n", expl);
hand[0].rank = 0;
hand[1].rank = 1;
hand[2].rank = 2;
hand[3].rank = 3;
hand[4].rank = 4;
hand[0].suit = 0;
hand[1].suit = 0;
hand[2].suit = 0;
hand[3].suit = 0;
hand[4].suit = 1;
printf("scorehand of crib = %d\n", scorehand(hand, hand[4], CINHAND, TRUE, TRUE));
printf("\t%s\n", expl);
# endif
}
|