(no message)
authorKen Arnold <arnold@ucbvax.Berkeley.EDU>
Wed, 7 Sep 1983 03:51:42 +0000 (19:51 -0800)
committerKen Arnold <arnold@ucbvax.Berkeley.EDU>
Wed, 7 Sep 1983 03:51:42 +0000 (19:51 -0800)
SCCS-vsn: games/cribbage/test.c 1.3

usr/src/games/cribbage/test.c

index 09e9f96..397e2de 100644 (file)
@@ -1,4 +1,4 @@
-static char    *sccsid = "@(#)test.c   1.2 (Berkeley) %G%";
+static char    *sccsid = "@(#)test.c   1.3 (Berkeley) %G%";
 
 #include       <stdio.h>
 #include       "deck.h"
 
 #include       <stdio.h>
 #include       "deck.h"
@@ -17,9 +17,10 @@ main( argc, argv )
     char       *argv[];
 {
        register  int           k, l, m;
     char       *argv[];
 {
        register  int           k, l, m;
-       int                     i, j, is, n, sum;
+       int                     i, j, is, n, sum, sum2;
        CARD                    ic, jc;
        CARD                    d[ CARDS];
        CARD                    ic, jc;
        CARD                    d[ CARDS];
+       extern char             expl[];
 
        printf( "Assuming cards are same suit\n" );
        if(  argc == 2  )  {
 
        printf( "Assuming cards are same suit\n" );
        if(  argc == 2  )  {
@@ -27,12 +28,14 @@ main( argc, argv )
            printf( "Starting at i = %d\n", is );
        }
        makedeck( deck );
            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++ )  {
        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: 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;
            }
            for( j = i + 1; j < RANKS; j++ )  {         /* second card */
                jc.rank = j;
@@ -43,20 +46,72 @@ main( argc, argv )
                remove( ic, d, n-- );
                remove( jc, d, n-- );
                sum = 0;
                remove( ic, d, n-- );
                remove( 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  )
                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 );
+                                           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: sum  = %d\n", i, j, sum );
+               printf( "%d %d: sum2 = %d\n", i, j, sum2 );
                fflush( stdout );
            }
        }
        printf( "\nthe hand scores %d\n", i );
                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
 }
 }
-