int main(int argc, char const *argv[]) { int i, j, k; struct gameState G; printf("Random Card Test 2: Testing Adventurer\n"); //Set up random number generation SelectStream(2); PutSeed(3); //Random Testing for (i = 0; i < 2000; i++) { for (j = 0; j < sizeof(struct gameState); j++) { ((char*)&G)[j] = floor(Random() * 256); } //Randomize players & decks k = floor(Random() * MAX_PLAYERS); G.whoseTurn = k; G.deckCount[k] = floor(Random() * MAX_DECK); G.discardCount[k] = floor(Random() * MAX_DECK); G.handCount[k] = floor(Random() * MAX_HAND); G.playedCardCount = floor(Random() * MAX_DECK); testAdventurer(&G); } return 0; }
int main(int argc, char *argv[]) { struct gameState *G1 = malloc(sizeof(struct gameState)); struct gameState *G2 = malloc(sizeof(struct gameState)); int k[10] = {adventurer, council_room, embargo, village, minion, mine, cutpurse, sea_hag, tribute, smithy}; initializeGame(2, k, 2, G1); initializeGame(2, k, 2, G2); testAdventurer(G1, G2); return 0; }
//main function for starting the 250 tests int main() { int p = 0;//testing player 0 struct gameState G;//creating new game state int numTests = 250; //250 tests int k, m, j, n, i; //random game state for (i = 0; i < sizeof(struct gameState); i++) { ((char*)&G)[i] = floor(Random() * 256); } G.whoseTurn = p;//setting whoseTurn to 0 SelectStream(2); PutSeed(3); printf("----------------- Testing card: %s ----------------\n", TESTCARD); for(k = 0; k < numTests; k++) { //filling in random cards based on lecture 11 and 12 Random Testing G.handCount[p] = floor(Random() * MAX_HAND)+1;//need at least one adventurer in our hand G.deckCount[p] = floor(Random() * MAX_DECK);//from lecture 11 to generate random deck G.discardCount[p] = floor(Random() * MAX_DECK);//from lecture 11 to generate random discard for(m = 0; m < G.handCount[p]; m++) { G.hand[p][m] = floor(Random() * treasure_map) + 1; } for(j = 0; j < G.discardCount[p]; j++) { G.discard[p][j] = floor(Random() * treasure_map) + 1; } for(n = 0; n < G.deckCount[p]; n++) { G.deck[p][n] = floor(Random() * treasure_map) + 1; } testAdventurer(&G);//run tests } printf("Play Adventurer Tests are concluded.\n\n"); return 0; }
int main() { int p = 0; struct gameState G; int numTests = 500; int k, m, j, n, i; for (i = 0; i < sizeof(struct gameState); i++) { //from the lessons, random gameState ((char*)&G)[i] = floor(Random() * 256); } G.whoseTurn = p; SelectStream(2); PutSeed(3); printf("Testing playAdventurer() cardtest2.\n"); for(k = 0; k < numTests; k++) { //fill in random cards G.handCount[p] = floor(Random() * MAX_HAND)+1;//need at least one adventurer in our hand G.deckCount[p] = floor(Random() * MAX_DECK); G.discardCount[p] = floor(Random() * MAX_DECK); for(m = 0; m < G.handCount[p]; m++) { G.hand[p][m] = floor(Random() * treasure_map) + 1; } for(j = 0; j < G.discardCount[p]; j++) { G.discard[p][j] = floor(Random() * treasure_map) + 1; } for(n = 0; n < G.deckCount[p]; n++) { G.deck[p][n] = floor(Random() * treasure_map) + 1; } testAdventurer(&G); } printf("PLAYADVENTURER TESTS FINISHED.\n\n"); return 0; }
int main(int argc, char **argv){ SelectStream(2); PutSeed(time(NULL)); if(argc < 2){ printf("Usage: cardtest4 <number of times to run>\n"); return 1; } int loops = atoi(argv[1]); int i, failures = 0; struct gameState G; for(i = 0; i < loops; i++) { setupState(&G); failures += testAdventurer(&G, i); } printf("Tests Run: %d, Tests passed: %d, Tests failed: %d\n", loops, loops - failures, failures); return 0; }
int main() { return testAdventurer(); }
int main(int argc, char *argv[]) { testAdventurer(); return 0; }
int main(int argc, char *argv[]) { srand(time(NULL)); testAdventurer(); return 0; }
int main() { //s1 will hold state after initialization, s2 will be state after draw card struct gameState *gs1 = malloc(sizeof(struct gameState)); struct gameState *gs2 = malloc(sizeof(struct gameState)); //Cards used in test instance of game int gameCards[10] = {smithy, adventurer, council_room, feast, gardens, mine, remodel, village, baron, great_hall}; int numPlayers; int seed = 55; int player, i; int passed = 0; int numDiscarded; int coinIncrease; int tempHand[MAX_HAND]; numPlayers = 4; if (initializeGame(numPlayers, gameCards, seed, gs1) == -1) { printf("Game state failed to initialize. No testing completed.\n"); return -1; } player = 0; //Test for two gold cards taken from top of deck //Set up the deck for testing with only two treasure cards in desired spots for (i = 0; i < gs1->deckCount[player]; i++) { if (i == (gs1->deckCount[player] - 1) || i == (gs1->deckCount[player] - 2)) gs1->deck[player][i] = gold; else gs1->deck[player][i] = estate; } //Put adventurer card in player's hand and set rest of cards to estate for (i = 0; i < gs1->handCount[player]; i++) { if (i == 0) gs1->hand[player][i] = adventurer; else gs1->hand[player][i] = estate; } //Set up state so that card can be played gs1->coins = 0; gs1->numActions = 1; gs1->phase = 0; //Copy state for comparison after call to playAdventurer memcpy(gs2, gs1, sizeof(struct gameState)); numDiscarded = 0; coinIncrease = 6; //playAdventurer(player, 0, 0, tempHand, gs1); if (playCard(0, 0, 0, 0, gs1) == -1) printf("Error in call to playCard() for adventurer.\n"); printf("Testing two gold coins at top of deck.\n"); if (testAdventurer(gs2, gs1, player, numDiscarded, coinIncrease) != -1) printf("PASS all tests for two gold coins at top of deck.\n"); //Reset game state to original state before next test memcpy(gs1, gs2, sizeof(struct gameState)); if (initializeGame(numPlayers, gameCards, seed, gs1) == -1) { printf("Game state failed to initialize. No testing completed.\n"); return -1; } //Test for two silver cards at bottom of deck //Set up the deck for testing with only two treasure cards in desired spots for (i = 0; i < gs1->deckCount[player]; i++) { if (i == 0 || i == 1) gs1->deck[player][i] = silver; else gs1->deck[player][i] = estate; } //Put adventurer card in player's hand and set rest of cards to estate for (i = 0; i < gs1->handCount[player]; i++) { if (i == 0) gs1->hand[player][i] = adventurer; else gs1->hand[player][i] = estate; } //Set up state so that card can be played gs1->coins = 0; gs1->numActions = 1; gs1->phase = 0; //Copy state for comparison after call to playAdventurer memcpy(gs2, gs1, sizeof(struct gameState)); numDiscarded = 3; coinIncrease = 4; //playAdventurer(player, 0, 0, tempHand, gs1); if (playCard(0, 0, 0, 0, gs1) == -1) printf("Error in call to playCard() for adventurer.\n"); printf("Testing two silver coins at bottom of deck.\n"); if (testAdventurer(gs2, gs1, player, numDiscarded, coinIncrease) != -1) printf("PASS all tests for two silvers at bottom of deck.\n"); if (initializeGame(numPlayers, gameCards, seed, gs1) == -1) { printf("Game state failed to initialize. No testing completed.\n"); return -1; } //Test for gold and silver split in deck //Set up the deck for testing with only two treasure cards in desired spots for (i = 0; i < gs1->deckCount[player]; i++) { if (i == 0) gs1->deck[player][i] = gold; else if (i == gs1->deckCount[player] - 1) gs1->deck[player][i] = silver; else gs1->deck[player][i] = estate; } //Put adventurer card in player's hand and set rest of cards to estate for (i = 0; i < gs1->handCount[player]; i++) { if (i == 0) gs1->hand[player][i] = adventurer; else gs1->hand[player][i] = estate; } //Set up state so that card can be played gs1->coins = 0; gs1->numActions = 1; gs1->phase = 0; //Copy state for comparison after call to playAdventurer memcpy(gs2, gs1, sizeof(struct gameState)); numDiscarded = 3; coinIncrease = 5; //playAdventurer(player, 0, 0, tempHand, gs1); if (playCard(0, 0, 0, 0, gs1) == -1) printf("Error in call to playCard() for adventurer.\n"); printf("Testing gold and silver coins split in deck.\n"); if (testAdventurer(gs2, gs1, player, numDiscarded, coinIncrease) != -1) printf("PASS all tests for gold and silver split in deck.\n"); if (initializeGame(numPlayers, gameCards, seed, gs1) == -1) { printf("Game state failed to initialize. No testing completed.\n"); return -1; } //Test for gold and copper split deck //Set up the deck for testing with only two treasure cards in desired spots for (i = 0; i < gs1->deckCount[player]; i++) { if (i == 0) gs1->deck[player][i] = copper; else if (i == 4) gs1->deck[player][i] = gold; else gs1->deck[player][i] = estate; } //Put adventurer card in player's hand and set rest of cards to estate for (i = 0; i < gs1->handCount[player]; i++) { if (i == 0) gs1->hand[player][i] = adventurer; else gs1->hand[player][i] = estate; } //Set up state so that card can be played gs1->coins = 0; gs1->numActions = 1; gs1->phase = 0; //Copy state for comparison after call to playAdventurer memcpy(gs2, gs1, sizeof(struct gameState)); numDiscarded = 3; coinIncrease = 4; //playAdventurer(player, 0, 0, tempHand, gs1); if (playCard(0, 0, 0, 0, gs1) == -1) printf("Error in call to playCard() for adventurer.\n"); printf("Testing gold and copper coins split deck.\n"); if (testAdventurer(gs2, gs1, player, numDiscarded, coinIncrease) != -1) printf("PASS all tests for gold and copper split in deck.\n"); if (initializeGame(numPlayers, gameCards, seed, gs1) == -1) { printf("Game state failed to initialize. No testing completed.\n"); return -1; } //Testing silver and copper requiring a shuffle //Set all cards in deck to non-treasure cards so playAdventurer will call shuffle for (i = 0; i < 5; i++) gs1->hand[player][i] = estate; //Set up deck with two treasure cards that should be drawn after shuffle gs1->deckCount[player] = 2; gs1->deck[player][0] = silver; gs1->deck[player][1] = copper; //Set up player's hand and game state conditions for (i = 0; i < gs1->handCount[player]; i++) { if (i == 0) gs1->hand[player][i] = adventurer; else gs1->hand[player][i] = estate; } //Set up state so that card can be played gs1->coins = 0; gs1->numActions = 1; gs1->phase = 0; //Copy state for comparison after call to playAdventurer memcpy(gs2, gs1, sizeof(struct gameState)); numDiscarded = 5; coinIncrease = 3; //playAdventurer(player, 0, 0, tempHand, gs1); if (playCard(0, 0, 0, 0, gs1) == -1) printf("Error in call to playCard() for adventurer.\n"); printf("Testing silver and copper coins in shuffle scenario.\n"); printf("Ignore error messages related to discard count or deck count.\n"); if (testAdventurer(gs2, gs1, player, numDiscarded, coinIncrease) != -1) printf("PASS all tests for silver and copper split in shuffle scenario.\n"); return 0; }
int main () { int n, p, i; struct gameState G; time_t t; srand((unsigned)time(&t)); printf ("Testing Adventurer.\n"); printf ("RANDOM TESTS.\n"); SelectStream(2); PutSeed(3); for (n = 0; n < 2000; n++) { int* k=kingdomCards(1,2,3,4,5,6,7,8,9,10); G.numPlayers=rand() % 3+1; initializeGame(G.numPlayers,k,1000,&G); p = rand() % 2+1; G.numPlayers=rand() % 3+1; G.deckCount[p] = rand() % MAX_DECK; G.discardCount[p] = rand() % MAX_DECK; G.handCount[p] = rand() % MAX_HAND; G.supplyCount[adventurer]=rand()%10; testAdventurer(&G,p); } printf ("Fixed tests for adventurer():\n"); for (i=0;i<50;i++) { int* k=kingdomCards(1,2,3,4,5,6,7,8,9,10); memset(&G, 23, sizeof(struct gameState)); // clear the game state initializeGame(2, k, 1000, &G); // initialize a new game G.handCount[0]=0; #if (NOISY_TEST == 1) printf ("Playing adventurer card 1 time\n"); #endif adventurerCard(1,&G); #if (NOISY_TEST == 1) printf("Handcount: %d\n", G.handCount[0]); printf("Number of Cards Played = %d, expected = 0", G.playedCardCount); if (G.playedCardCount==0) { printf("....PASS\n"); } else{ printf("....FAIL\n"); } printf ("Playing adventurer card another time\n"); #endif adventurerCard(1,&G); #if (NOISY_TEST == 1) printf("Handcount: %d\n", G.handCount[0]); printf("Number of Cards Played = %d, expected = 0", G.playedCardCount); if (G.playedCardCount==0) { printf("....PASS\n"); } else{ printf("....FAIL\n"); } printf ("Playing adventurer card another time\n"); #endif adventurerCard(1,&G); #if (NOISY_TEST == 1) printf("Handcount: %d\n", G.handCount[0]); printf("Number of Cards Played = %d, expected = 0", G.playedCardCount); if (G.playedCardCount==0) { printf("....PASS\n"); } else{ printf("....FAIL\n"); } printf ("Playing adventurer card another time\n"); #endif adventurerCard(1,&G); #if (NOISY_TEST == 1) printf("Handcount: %d\n", G.handCount[0]); printf("Number of Cards Played = %d, expected = 0", G.playedCardCount); if (G.playedCardCount==0) { printf("....PASS\n"); } else{ printf("....FAIL\n"); } printf ("Playing adventurer card another time\n"); #endif adventurerCard(1,&G); #if (NOISY_TEST == 1) printf("Handcount: %d\n", G.handCount[0]); printf("Number of Cards Played = %d, expected = 0", G.playedCardCount); if (G.playedCardCount==0) { printf("....PASS\n"); } else{ printf("....FAIL\n"); } printf ("Playing adventurer card another time\n"); #endif adventurerCard(1,&G); #if (NOISY_TEST == 1) printf("Handcount: %d\n", G.handCount[0]); printf("Number of Cards Played = %d, expected = 0", G.playedCardCount); if (G.playedCardCount==0) { printf("....PASS\n"); } else{ printf("....FAIL\n"); } printf ("Playing adventurer card another time*\n"); #endif adventurerCard(1,&G); #if (NOISY_TEST == 1) printf("Handcount: %d\n", G.handCount[0]); printf("Number of Cards Played = %d, expected = 0", G.playedCardCount); if (G.playedCardCount==0) { printf("....PASS\n\n"); } else{ printf("....FAIL\n\n"); } #endif endTurn(&G); #if (NOISY_TEST == 1) printf("Testing other player's hand\n"); printf("Number of Cards Played = %d, expected = 0", G.playedCardCount); if (G.playedCardCount==0) { printf("....PASS\n"); } else{ printf("....FAIL\n"); } printf("Hand Count = %d, expected = 0", G.handCount[0]); if (G.handCount[0]==0) { printf("....PASS\n\n"); } else{ printf("....FAIL\n\n"); } #endif } printf ("ALL TESTS COMPLETE\n"); return 0; }