Beispiel #1
0
int main() {
    int i, n;
    int thisPlayer;
    int handPos = 0;
	struct gameState G;

	// Random control
	SelectStream(2);
    PutSeed(3);

    printf("Random testing %s:\n", TESTCARD);
    for (n = 0; n < NUM_TESTS; n++) {\
        printf("\n >>>>> TEST %d <<<<<\n\n", n + 1);
        // randomize struct - from lecture
        for (i = 0; i < sizeof(struct gameState); i++) {
          ((char*)&G)[i] = floor(Random() * 256);
        }
        // generate random decks and hands for both players
        cardsForPlayers(&G);
        // randomly pick a player
        G.numActions = 0;
        thisPlayer = floor(Random() * 2);
        // make sure player hand has village to play
        do
        {
            handPos = Random() * G.handCount[thisPlayer];
        } while (handPos == G.handCount[thisPlayer]);
        G.hand[thisPlayer][handPos] = village;
        checkVillage(thisPlayer, &G, handPos);
    }

	printf("\n >>>>> SUCCESS: Random testing complete: %s <<<<<\n\n", TESTCARD);

	return 0;
}
Beispiel #2
0
int main (){
   
     int seed = 1000;
     int r,i;
     int result = 0;
     bool pass = true;
     int p=0;
     int handPos;

     int k[10] = { adventurer, council_room, feast, gardens, mine
          , remodel, smithy, village, baron, great_hall };
     struct gameState G;
     

     printf("TESTING VILLAGE CARD\n");

     for(p=0; p<MAX_PLAYERS; p++){
       
       switch(p){
         case 0:
           printf("Testing for village card at index 0 of hand\n");
           break;
         case 1: 
           printf("Testing for village card at last index of hand\n");
           break;
         case 2:
           printf("Normal testing mode\n");
           break;
         case 3:
           printf("Normal testing mode\n");
           break;
       }
       memset(&G, 23, sizeof(struct gameState));   // clear the game state
       r = initializeGame(MAX_PLAYERS, k, seed, &G); // initialize a new game
       //set deck for each player
       setDeck(&G);
       //change each player's hand, with at least 1 village card
       setHand(&G);
       //set handpos of village card
       for(i=0; i< G.handCount[p]; i++){
         if(G.hand[p][i] == village){
           handPos = i;
         }
       }

       result = checkVillage(p, &G, handPos);
       if (result == -1){
            pass = false;
       }


       if (pass == true){
         printf("ALL TESTS PASSED!\n");
       }else{
         printf("FAILURES\n");
       }

     }


  return 0;
}