|
|
1.1 ! root 1: static char *sccsid = "@(#)test.c 1.3 (Berkeley) 9/6/83"; ! 2: ! 3: #include <stdio.h> ! 4: #include "deck.h" ! 5: ! 6: ! 7: CARD known[ CARDS ]; /* a deck */ ! 8: CARD deck[ CARDS ]; /* a deck */ ! 9: CARD hand[ 4 ]; /* a hand */ ! 10: ! 11: int knownum; ! 12: ! 13: ! 14: main( argc, argv ) ! 15: ! 16: int argc; ! 17: char *argv[]; ! 18: { ! 19: register int k, l, m; ! 20: int i, j, is, n, sum, sum2; ! 21: CARD ic, jc; ! 22: CARD d[ CARDS]; ! 23: extern char expl[]; ! 24: ! 25: printf( "Assuming cards are same suit\n" ); ! 26: if( argc == 2 ) { ! 27: is = atoi( *++argv ); ! 28: printf( "Starting at i = %d\n", is ); ! 29: } ! 30: makedeck( deck ); ! 31: # if 0 ! 32: for( i = is; i < RANKS; i++ ) { /* first card */ ! 33: ic.rank = i; ! 34: ic.suit = 0; ! 35: hand[0] = ic; ! 36: for( j = 0; j <= i; j++ ) { ! 37: printf( "%d %d: sum = %d\n", i, j, -10000000 ); ! 38: printf( "%d %d: sum2 = %d\n", i, j, -10000000 ); ! 39: } ! 40: for( j = i + 1; j < RANKS; j++ ) { /* second card */ ! 41: jc.rank = j; ! 42: jc.suit = 0; ! 43: hand[1] = jc; ! 44: for( k = 0; k < CARDS; k++ ) d[k] = deck[k]; ! 45: n = CARDS; ! 46: remove( ic, d, n-- ); ! 47: remove( jc, d, n-- ); ! 48: sum = 0; ! 49: sum2 = 0; ! 50: for( k = 0; k < n - 1; k++ ) { /* 3rd card */ ! 51: hand[2] = d[k]; ! 52: for( l = k + 1; l < n; l++ ) { /* 4th card */ ! 53: hand[3] = d[l]; ! 54: for( m = 0; m < n; m++ ) { /* cut card */ ! 55: if( m != l && m != k ) ! 56: sum += scorehand(hand, d[m], 4, FALSE, FALSE); ! 57: sum2 += scorehand(hand, d[m], 4, TRUE, FALSE); ! 58: } ! 59: } ! 60: } ! 61: printf( "%d %d: sum = %d\n", i, j, sum ); ! 62: printf( "%d %d: sum2 = %d\n", i, j, sum2 ); ! 63: fflush( stdout ); ! 64: } ! 65: } ! 66: printf( "\nthe hand scores %d\n", i ); ! 67: # else ! 68: hand[0].rank = 0; ! 69: hand[1].rank = 1; ! 70: hand[2].rank = 2; ! 71: hand[3].rank = 3; ! 72: hand[4].rank = 4; ! 73: hand[0].suit = 0; ! 74: hand[1].suit = 0; ! 75: hand[2].suit = 0; ! 76: hand[3].suit = 0; ! 77: hand[4].suit = 0; ! 78: printf("scorehand of hand = %d\n", scorehand(hand, hand[4], CINHAND, FALSE, TRUE)); ! 79: printf("\t%s\n", expl); ! 80: hand[0].rank = 0; ! 81: hand[1].rank = 1; ! 82: hand[2].rank = 2; ! 83: hand[3].rank = 3; ! 84: hand[4].rank = 4; ! 85: hand[0].suit = 0; ! 86: hand[1].suit = 0; ! 87: hand[2].suit = 0; ! 88: hand[3].suit = 0; ! 89: hand[4].suit = 0; ! 90: printf("scorehand of crib = %d\n", scorehand(hand, hand[4], CINHAND, TRUE, TRUE)); ! 91: printf("\t%s\n", expl); ! 92: hand[0].rank = 0; ! 93: hand[1].rank = 1; ! 94: hand[2].rank = 2; ! 95: hand[3].rank = 3; ! 96: hand[4].rank = 4; ! 97: hand[0].suit = 0; ! 98: hand[1].suit = 0; ! 99: hand[2].suit = 0; ! 100: hand[3].suit = 0; ! 101: hand[4].suit = 1; ! 102: printf("scorehand of hand = %d\n", scorehand(hand, hand[4], CINHAND, FALSE, TRUE)); ! 103: printf("\t%s\n", expl); ! 104: hand[0].rank = 0; ! 105: hand[1].rank = 1; ! 106: hand[2].rank = 2; ! 107: hand[3].rank = 3; ! 108: hand[4].rank = 4; ! 109: hand[0].suit = 0; ! 110: hand[1].suit = 0; ! 111: hand[2].suit = 0; ! 112: hand[3].suit = 0; ! 113: hand[4].suit = 1; ! 114: printf("scorehand of crib = %d\n", scorehand(hand, hand[4], CINHAND, TRUE, TRUE)); ! 115: printf("\t%s\n", expl); ! 116: # endif ! 117: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.