// This methods is to check whether if the last piece you drop is in // an empty hole on your side, you capture that piece and any pieces // in the hole directly opposite void doCapture(int player, Hole board[], int index){ int indexOpp; indexOpp = 12 - index; if (printFlag) { displayBoard(board); } if(player == 0 && index >= 0 && index <= 5){ if (printFlag) { printf("Squares in column %c are captured.\n", index + 'A'); } board[6].capacity += (board[index].capacity + board[indexOpp].capacity); board[index].capacity = 0; board[indexOpp].capacity = 0; if (printFlag) { displayBoard(board); } }else if(player == 1 && index >= 7 && index <= 12){ if (printFlag) { printf("Squares in column %c are captured.\n", 12 - index + 'A'); } board[13].capacity += (board[index].capacity + board[indexOpp].capacity); board[index].capacity = 0; board[indexOpp].capacity = 0; if (printFlag) { displayBoard(board); } } }// end of doCapture
//Method to Move Between Players void TicTacToe::PlayerMovement() { do { for (int i = 0; i < currentPlayer; i++) { cout << endl; int selectROW; int selectCOL; int counter1 = 0; do { cout << "@" << players[i].getHandle() << ": Please enter the row and column " << "for the space you want to mark: "; cin >> selectROW >> selectCOL; counter1++; } while (!setMarker(selectROW, selectCOL, players[i].getMarker())); if((WinnerCheck(players[i].getMarker()))) { if(i == 0) { Player::IncrementWinsP1(); totalWins++; displayBoard(); WinnerMessage(players[i].getHandle()); NoWinner = false; break; } else if(i == 1) { Player::IncrementWinsP2(); totalWins++; displayBoard(); WinnerMessage(players[i].getHandle()); NoWinner = false; break; } } else if ((TieCheck(players[i].getMarker()))) { TieMessage(); ties++; NoWinner = false; displayBoard(); break; } else { displayBoard(); } } } while (NoWinner); }
int main() { char board[height][width]; initBoard(board); displayBoard(board); char p[2][80]; int x=0,y=0; for(int i=0,t=0;t<7;i++,t++){ printf("\nPlayer %i, please enter your selection: ",(i+1)); scanf("%s",&p[i][0]); switch(toUpper(p[i][0])){ case 'A': x=0; break; case 'B': x=1; break; case 'C': x=2; break; default: printf("%s is not a valid option.\n",&p[i--][0]); t--; continue; break; } switch(p[i][1]){ case '1':y=0; break; case '2':y=1; break; case '3':y=2; break; default: printf("%s is not a valid option.\n",&p[i--][1]); t--; continue; break; } if(board[y][x]=='*'){ board[y][x]=(i==0)?'X':'O'; i=(i==1)?-1:i; } else { printf("Player %i has already marked this spot.\n",i--); t--; } displayBoard(board); if(t>=3) switch(determineWinOrTie(board)){ case 0: if(t>=6) {puts("It's a tie.");return 0;} break; case 1: puts("Player one wins."); return 0; case 2: puts("Player two wins."); return 0; default:puts("An error occured."); break; } } return 0; }
// 描画の際呼び出される void display() { glClear(GL_COLOR_BUFFER_BIT); // ボード基盤描画 displayBoard(); displayBombNum(owner->Model()->Bomb(),owner->Model()->getFlagNum()); displayTime(owner->Timer()->getElapsedTime()); if (!owner->First()) { // 押されたマス目とフラグ描画 for (int i = 0; i < sqrNum; i++) { for (int j = 0; j < sqrNum; j++) { if (owner->Board(i,j)->Pushed()) { // 押されたマスを描画 displayPushedPiece(i, j, owner->Board(i,j)->Num()); } else if (owner->Board(i, j)->Flag()) { // フラグが立ててあるマスを描画 displayFlagPiece(i, j); } } } } if (owner->Clear()) { displayGrayBand(); displaySentenceOnBandRandom(" Congratulations!"); } glutSwapBuffers(); }
void displayInfo(int board[4][4], int move_score[4], MoveDirection move) { displayBoard(board); displayScore(move_score); displayMove(move); printf("-------------------------\n"); }
void getBoard(Cell board[BOARD_HEIGHT][BOARD_WIDTH],char * token){ if(strcmp(token,"1") == 0) { loadBoard(board, BOARD_1); displayBoard(board,NULL); } else if(strcmp(token,"2") == 0) { loadBoard(board, BOARD_2); displayBoard(board,NULL); } else { printf("ERROR : INVALID INPUT.\n\n"); printf("Please enter a correct command.\n"); } }
int main(int argc, char *argv[]){ lHead = NULL; printFlag = 1; printf("Author: Muxuan Wang\n"); printf("Program 5: Mancala\n"); printf("TA: Sean Deitz, W 9:00 AM\n"); printf("Nov.28,2012\n"); printf("\n"); printf("Welcome to the game of Mancala, where you are playing against\n"); printf("a computer opponent. You may enter 'u' to undo a move or \n"); printf("'x' to exit. Your holes are on the bottom row and you get\n"); printf("to go first.\n"); printf("\n"); printf("\n"); Hole board[14]; initBoard(board); if (argc > 1) { commandLineArg(board, argv); } addToTail(&lHead, board); int player = 0; char userInput; int notDone = 1; int gameNum = 1; //each loop is a turn, and involves user and computer to play. while(notDone){ printf("----------------------------------------------------------\n"); playerToMove(player,board, &gameNum); notDone = checkEndGame(board); if (notDone == 0) { break; } player = (++player) % 2; playerToMove(player,board, &gameNum); notDone = checkEndGame(board); gameNum++; player = (++player) % 2; addToTail(&lHead, board); } endGameScore(board); printf("The final board is: \n"); displayBoard(board); if(board[13].capacity > board[6].capacity){ printf("Computer Won!!\n"); }else if(board[13].capacity < board[6].capacity){ printf("You Won!!\n"); }else{ printf("Play Even!!"); } } // end of main
void display() { glClear(GL_COLOR_BUFFER_BIT); displayBoard(game); sb->display(); glFlush(); glutSwapBuffers(); }
bool TicTacToeGame::isGameOver() const { displayBoard(); bool bGameOver = checkColumns(); bGameOver |= checkRows(); bGameOver |= checkDiagonals(); return bGameOver; }
int main(void) { int fini,x,y; fini=0; initPlayer(); createBoard(); while(!fini) { displayBoard(); if(getPlayer()==CROSS) { printf("Cross to play\n"); } else { printf("Circle to play\n"); } printf("column?: "); scanf("%d",&x); printf("line?: "); scanf("%d",&y); if(putPiece(x,y,getPlayer())==0) { fini=checkGameStatus(); if(!fini) { changePlayer(); } }else { printf("you can't play here!\n"); } } displayBoard(); if(getPlayer()==CROSS) { printf("Cross won \\o/\n"); } else { printf("Circle won \\o/\n"); } }
int main(int argc,char **argv) { int i; char **mineBoard = 0; char **statusBoard = 0; //for(i=0;i<argc;i++) //printf("argv[%d] = %s\n",i,argv[i]); int rows = atoi(argv[1]) + 1; //printf("rows = %d\n",rows); int colums = atoi(argv[2]) + 1; //printf("cols = %d\n",colums); int mines = atoi(argv[3]); //printf("mines = %d\n",mines); mineBoard = makeEmptyBoard(mineBoard,rows,colums); //printf("\n"); statusBoard = makeEmptyBoard(statusBoard,rows,colums); //printf("\n"); //printf("rows = %d\n",rows); //printf("cols = %d\n",colums); //displayBoard(mineBoard,rows,colums); //displayBoard(statusBoard,rows,colums); coverBoard(statusBoard,rows,colums); displayBoard(statusBoard,rows,colums); mineBoard = placeMines(rows,colums,mines,mineBoard); mineBoard = fillBoard(mineBoard,rows,colums); displayBoard(mineBoard,rows,colums); /*int r,c; for (r=0;r<rows;r++) { for (c=0;c<colums;c++) { printf("[%c] ",mineBoard[r][c]); } printf("\n"); }*/ //free(mineBoard); //free(statusBoard); return 0; }
//Method to Initiate the Game void TicTacToe::initiateGame() { ClearBoard(); gameRules(); cout << endl; cout << endl; displayBoard(); numGamesPlayed++; }
//Using linked list to implement undo. void undo(Hole board[], int *gameNum) { if (len(lHead) == 1) { printf("Sorry, you cannot undo past the beginning of the game. Please retry move.\n"); return; } deleteLastNode(&lHead); State* n = getTail(lHead); copyBoard(board, n->data); displayBoard(board); *gameNum -= 1; }
void Game::display() { player->display(); for (auto bullet : bullets) bullet->display(); for (auto enemy : enemies) enemy->display(); displayBoard(); }
int main(void) { char ** board = newBoard(); // print top row of numbers PickPiece(board); // return contents; displayBoard(board); }
void getNextMove(Cell board[BOARD_HEIGHT][BOARD_WIDTH], char * token,Player * player){ if ((strcmp(token,COMMAND_FORWARD) == 0) || (strcmp(token,COMMAND_FORWARD_SHORTCUT) == 0)) { movePlayerForward(board,player); displayBoard(board,player); } else if ((strcmp(token,COMMAND_TURN_LEFT) == 0) || (strcmp(token,COMMAND_TURN_LEFT_SHORTCUT) == 0)) { turnDirection(player,TURN_LEFT); displayBoard(board,player); } else if ((strcmp(token,COMMAND_TURN_RIGHT) == 0) || (strcmp(token,COMMAND_TURN_RIGHT_SHORTCUT) == 0)) { turnDirection(player,TURN_RIGHT); displayBoard(board,player); } else{ printf("Please try agian :)\n"); } }
// The function is to process a player's move from displaying the board, getting // user input to dealing with user input. // It takes player, board array and gameNum as parameter. // gameNum is used to record how many turns the user and computer have played. void playerToMove(int player,Hole board[],int* gameNum){ char userInput; int playerDone = 0; int i = 0; do{ if ((player == 1 && i > 0) || player == 0) displayBoard(board); userInput = getUserInput(player, gameNum, playerDone, board); playerDone = pieceToMove(player, userInput, board); if(checkEndGame(board) == 0) break; i++; }while (playerDone); } //end of playerToMove
void main(void) { DisableInterrupts; initializations(); EnableInterrupts; turnOffLEDs(); // reset game on startup resetGame(); TC7 = 15000; //set up TIM TC7 to generate 0.1 ms interrupt rate for(;;) { displayBoard(); if (interuptFlag) { tickCounter++; ticksSinceLastEvolution++; if (ticksSinceLastEvolution >= TICKS_BETWEEN_EVOLUTIONS) { ticksSinceLastEvolution = 0; evolveFlag = 1; } } if (evolveFlag) { evolveFlag = 0; evolve(); } if (boardsAreSame == 1) { resetGame(); } // check to see if the user would like to reset the game (presses right push button) if (rghtpb == 1) { rghtpb = 0; resetGame(); } _FEED_COP(); /* feeds the watchdog timer */ } /* loop forever */ /* make sure that you never leave main */ }
int main() { int s = 1; printf("---Program starts---\n"); // checking Tile condition if (getTileType(153) != 'W') printf("153 should return W"); else if (getTileType(65) != 'L') printf("65 should return L"); else if (getTileType(49) != 'G') printf("49 should return G"); else if (getTileType(0) != 'C') printf("0 should return C"); else if (getTileType(105) != 'G') printf("105 should be G"); else if (getTileType(79) != ' ') printf("79 should be space"); else { printf("getTileType test passed!\nEnter board size: "); scanf_s("%d", &s); displayBoard(s); // Calling displayBoard function printf("---End Program---\n"); } return 0; }
// The function is to process a player's move from displaying the board, getting // user input to dealing with user input. // It takes player, board array and gameNum as parameter. // gameNum is used to record how many turns the user and computer have played. void playerToMove(int player,Hole board[],int gameNum){ char userInput; int playerDone = 0; do{ displayBoard(board); userInput = getUserInput(player, gameNum, playerDone, board); playerDone = pieceToMove(player, userInput, board); if(checkEndGame(board) == 0) break; }while (playerDone); //displayBoard(board); //printf("---------------------------------------------------\n sepertat"); /* if(oneGameDone){ */ /* printf("-----------------------------------------------------\n"); */ /* displayBoard(board); */ /* } */ } //end of playerToMove
CheckersBoard::CheckersBoard() { /* * In ASCII * 46 == '.' * 88 == 'X' * 79 == 'O' */ positions_ = { {1, 46}, {2, 88}, {3, 46}, {4, 88}, {5, 46}, {6, 88}, {7, 46}, {8, 88}, {9, 88}, {10, 46}, {11, 88}, {12, 46}, {13, 88}, {14, 46}, {15, 88}, {16, 46}, {17, 46}, {18, 88}, {19, 46}, {20, 88}, {21, 46}, {22, 88}, {23, 46}, {24, 88}, {25, 46}, {26, 46}, {27, 46}, {28, 46}, {29, 46}, {30, 46}, {31, 46}, {32, 46}, {33, 46}, {34, 46}, {35, 46}, {36, 46}, {37, 46}, {38, 46}, {39, 46}, {40, 46}, {41, 79}, {42, 46}, {43, 79}, {44, 46}, {45, 79}, {46, 46}, {47, 79}, {48, 46}, {49, 46}, {50, 79}, {51, 46}, {52, 79}, {53, 46}, {54, 79}, {55, 46}, {56, 79}, {57, 79}, {58, 46}, {59, 79}, {60, 46}, {61, 79}, {62, 46}, {63, 79}, {64, 46}}; displayRules(); displayBoard(); }
void executeCGOL(int x, int y, int seed) { Serial.println("executeCGOL\n"); b1 = (char*)malloc(sizeof(char)*x*y); b2 = (char*)malloc(sizeof(char)*x*y); fillBoard((char*)b1, x, y, seed); long itercount =0; while (itercount<MAX_GEN && aliveCount(b1, x,y)>3) { char *artemp = b1; b1=generate(b1,b2, x, y); b2 = artemp; // display board displayBoard(b1); delay(1000); if(!hasChanged(b1, b2, x, y)) { delay(60000); break; } } }
/*MAIN MENU * Displays main menu choices*/ void showMenu() { Cell board[BOARD_HEIGHT][BOARD_WIDTH]; while (TRUE) { int choice; printf("\n"); printf("Welcome to Car Board \n"); printf("-------------------- \n"); printf("1. Play game \n"); printf("2. Show student's information \n"); printf("3. Quit \n\n"); choice = validateNumber(); if (choice == 1) { showCommands(); initialiseBoard(board); displayBoard(board, NULL); printf("load <g>\n"); printf("quit\n\n"); initialiseGame(); } if (choice == 2) { showStudentInformation(); } if (choice == 3) { printf("\n"); printf("Good Bye!\n\n"); break; } } }
void uw_htmloutput(FILE *outP, GAME_AREA *ga, char ** inv, int inc, int is_interactive, int has_table, int init) { if((trxFp = fopen(TRAXSKELFILE, "r")) == NULL) exit(4); if (is_interactive) fprintf(outP, "Content-Type: text/html\n\n"); writeSkeleton(outP); displayTitle(outP, init); writeSkeleton(outP); displayHeader(outP, init); writeSkeleton(outP); displayMoves(outP, inv, inc, has_table, init); writeSkeleton(outP); displayBoard(outP, ga, has_table); writeSkeleton(outP); displayForm(outP, inv, inc, has_table, init); writeSkeleton(outP); fclose(trxFp); trxFp = NULL; }
int main(int argc, char* argv[]) { // set up board PositionType board[BoardSize][BoardSize]; int numberOfBombs = atoi(argv[1]); setBoard(board, numberOfBombs); // game loop int gameState, row, column; do { // ask for guess printf("Your move?: \n"); scanf("%d %d", &row, &column); printf("\n"); // process move gameState = processGuess(board, row - 1, column - 1); if (gameState == -1) { printf("Invalid move!\n\n"); } else if (gameState == 0) { printf("You've already played there!\n\n"); } // show the board displayBoard(board); printf("\n"); } while (gameState != 2 && hasWon(board) == 0); // game over, check for win or lose if (gameState != 2) { printf("YOU WIN!\n\n"); } else { printf("YOU LOSE!\n\n"); } return 0; }
int main(void){ BoardPtr board; NodePtr tempNode; int x, y, ext; LinkedListPtr p1, p2; //gfxInitDefault(); // graphics //gfxSet3D(false); // stereoscopy (true == on / false == off) u32 kDown; // keys down u32 kHeld; // keys pressed u32 kUp; // keys up u8* fbTopLeft; // top left screen's framebuffer u8* fbTopRight; // top right screen's framebuffer u8* fbBottom; // bottom screen's framebuffer gfxInitDefault(); PrintConsole topScreen, bottomScreen; consoleInit(GFX_TOP, &topScreen); consoleInit(GFX_BOTTOM, &bottomScreen); consoleClear(); gspWaitForVBlank(); p1 = (LinkedListPtr)malloc(sizeof(LinkedList)); p2 = (LinkedListPtr)malloc(sizeof(LinkedList)); board = initBoard(p1, p2); system("cls"); updateBoard(board, p1, p2); displayBoard(board, &topScreen, &bottomScreen); //p1 and p2 temporarily switched while(aptMainLoop()){ do{ do{ ext=takeTurn(board, "Player 1", p1, p2, p1, p2, &topScreen, &bottomScreen); refresh(board, p1, p2, &topScreen, &bottomScreen); }while(ext); if(p1->numPieces < 1 || p2->numPieces < 1) break; do{ ext=takeTurn(board, "Player 2", p2, p1, p1, p2, &topScreen, &bottomScreen); refresh(board, p1, p2, &topScreen, &bottomScreen); }while(ext); }while(p1->numPieces > 0 && p2->numPieces > 0); if(p1->numPieces < 1 && p1->numPieces != 0) { consoleClear(); printf("Player 2 wins!\n"); gspWaitForVBlank(); } if(p2->numPieces < 1 && p1->numPieces != 0){ consoleClear(); printf("Player 1 wins!\n"); gspWaitForVBlank(); } if(p1->numPieces == 0 && p2->numPieces == 0){ consoleClear(); gspWaitForVBlank(); return 0; } gfxFlushBuffers(); gfxSwapBuffers(); //Wait for VBlank gspWaitForVBlank(); } // Exit services gfxExit(); return 0; }
int main(int argc, char* argv[]){ if(argc==1){ printf("Incorrect number of command line arguments\n"); printf("Correct usage: ./a.out <number of bombs>\n"); return -1; } PositionType board[BoardSize][BoardSize]; int numberOfBomb=atoi(argv[1]); int totalNumberOfSafePlace=BoardSize*BoardSize-numberOfBomb; setBoard(board,numberOfBomb); displayBoard(board); printf("Game begins, there are total %d grids, and there are %d bombs there, %d total safe grids.\n", BoardSize*BoardSize, numberOfBomb, totalNumberOfSafePlace); int row; int col; printf("Enter a row and col:\n"); scanf("%d %d",&row,&col); int result; while(1){ result=processGuess( board, row , col ); switch(result){ case -1: printf("Invalid position.\n"); break; case 0: printf("That position has already been picked.\n"); break; case 1: totalNumberOfSafePlace--; break; case 2: printf("Game over, you lose\n"); displayBoard(board); return -1; } displayBoard(board); if(totalNumberOfSafePlace==0){ break; } printf("Total Number Of Safe Place Left: %d\n",totalNumberOfSafePlace); printf("Enter a row and col:\n"); scanf("%d %d",&row,&col); } printf("You win!\n"); return 0; }
/* allows you to pick pieces from a board board is the matrix created */ void PickPiece(char ** board) { int piece =0; // number as defined in menu bool is_vertical; int num_picked=0; bool orientation=false; bool piece1=false,piece2=false,piece3=false,piece4=false,piece5=false; char *response = malloc(Ship_Size); printf("Please type the number of the piece that you would like to place?\n"); while (num_picked<5) { displayBoard(board); printf("1: AIRCRAFT\n"); if (piece1) // if piece was used yet { piece1=true; num_picked++; } printf("2: BATTLESHIP \n"); if (piece2) // if piece was used yet { piece2=true; num_picked++; } printf("3: SUBMARINE \n"); if (piece3) // if piece was used yet { piece3=true; num_picked++; } printf("4: DESTROYER \n"); if (piece4) // if piece was used yet { piece4=true; num_picked++; } printf("5: PATROL BOAT \n"); if (piece5) // if piece was used yet { piece5=true; num_picked++; } if (!piece1 || !piece2 || !piece3 || !piece4 || !piece5) { scanf("%d", &piece); } int size=0; do { printf("What orientation would you like to have the piece (veritcal/horizontal)\n"); scanf("%s", response); if (WordExists(response, "horizontal")) { orientation=true; is_vertical=false; } else if (WordExists(response, "vertical")) { orientation=true; is_vertical=true; } }while (!orientation); switch (piece) { case 1: // aircraft picked size=5; break; case 2: // battleship picked size=4; break; case 3: // submarine picked size=3; break; case 4: // destroyer picked size=3; break; case 5: // patrol boat picked size=2; break; } placePiece_Begin(is_vertical, board, size); } }
void playGame(unsigned int boardSize, struct Player players[], unsigned int playerCount){ do{ int total = 0; int i, j, k, r = 1; for (i = 0; i < playerCount; i++){ displayBoard(boardSize, players, playerCount); printf("\n%s 's (%c) Turn ", players[i].playerName, players[i].id); total = playerRoll(); players[i].playerPosition += total; if (players[i].playerPosition >= (4 * boardSize - 4)){ players[i].playerPosition = players[i].playerPosition - (4 * boardSize - 4); } stealPrize(players, i, playerCount); if (players[i].playerPosition == 0){ //Analizing Prizes for (j = 0; j < 10; j++) { if (players[i].playerPrizes[j]>10 && players[i].playerPrizes[j]<200){ players[i].playerScore += players[i].playerPrizes[j]; } } if (players[i].playerScore>TOTAL_AMOUNT){ printf("___\n"); printf(" \\_______\n"); printf(" \\++++++|\n"); printf(" \\=====|\n"); printf(" 0--- 0\n"); printf("%s (%c) checked out for $%d\n", players[i].playerName, players[i].id, players[i].playerScore); return 0; } else{ printf("___\n"); printf(" \\_______\n"); printf(" \\++++++|\n"); printf(" \\=====|\n"); printf(" 0--- 0\n"); printf("%s (%c) checked out for $%d\n", players[i].playerName, players[i].id, players[i].playerScore); continue; } } else if (players[i].playerPosition % 3 == 0 && players[i].playerPosition % 5 == 0 && players[i].playerPosition % 7 == 0){ players[i].count = i; winGrandPrize(players); players[i].count = -1; } else if (players[i].playerPosition % 3 == 0 && players[i].playerPosition % 5 == 0){ players[i].count = i; loseItem(players); players[i].count = -1; } else if (players[i].playerPosition % 3 == 0){ players[i].count = i; winPrize(players); players[i].count = -1; } else if (players[i].playerPosition % 5 == 0){ players[i].count = i; loseItem(players); players[i].count = -1; } else if (players[i].playerPosition % 7 == 0){ players[i].count = i; winGrandPrize(players); players[i].count = -1; } else{ printf("You do nothing.\n"); } } } while (true); }
//main game loop that get the parameter from multiplayer() above. void gameLoop(std::pair < unsigned int, std::string> &result, const std::string &playerOne, const std::string &playerTwo, unsigned int &playerOneScore, unsigned int &playerTwoScore) { bool play = true; auto gameBoard = initBoard(); char turn = '1'; while ( play ) { ClearScreen(); displayBoard(gameBoard,playerOneScore,playerTwoScore,turn); if ( turn == '1' ) { pickSquare(gameBoard, '1', playerOne); //user enter move and modify the current gameBoard. if ( checkVictory(gameBoard) == true ) { playerOneScore++; ClearScreen(); displayBoard(gameBoard, playerOneScore, playerTwoScore, turn); //display current gameBoard std::cout << playerOne << " wins!" << std::endl; auto playAgainTemp = playAgain(); //use as temporary value to hold a boolean whether player wants to play again if ( playAgainTemp == true ) { std::cout << "Swapping turns..." << std::endl; delay(1); gameBoard = initBoard(); //create a new blank board ClearScreen(); swapTurn(turn); //the other player will start the new game displayBoard(gameBoard, playerOneScore, playerTwoScore, turn); } else if ( playAgainTemp == false ) { //if the player decides not to continue game after winning, result.first = playerOneScore; //the game will end by returning the current score at the end result.second = playerOne; //of current game to result (pair) for further processing (see play = false; //multiplayer() function above). } } else if ( checkVictory(gameBoard) == false ) { if ( checkDraw(gameBoard) == true ) { ClearScreen(); displayBoard(gameBoard, playerOneScore, playerTwoScore, turn); std::cout << "The game is drawn." << std::endl; auto playAgainTemp = playAgain(); if ( playAgainTemp == true ) { std::cout << "Swapping turns..." << std::endl; delay(1); gameBoard = initBoard(); ClearScreen(); swapTurn(turn); displayBoard(gameBoard, playerOneScore, playerTwoScore, turn); } else if ( playAgainTemp == false ) { play = false; //when draw, no high score will be recorded } } else if ( checkDraw(gameBoard) == false ) { swapTurn(turn); ClearScreen(); displayBoard(gameBoard, playerOneScore, playerTwoScore, turn); // continue to player 2 } } } if ( turn == '2' ) { //player 2 loop are exactly the same as player 1(except pickSquare(gameBoard, '2', playerTwo); //for the parameters that are being passed, which are if ( checkVictory(gameBoard) == true ) { //unique for player 2 for identification purposes playerTwoScore++; ClearScreen(); displayBoard(gameBoard, playerOneScore, playerTwoScore, turn); std::cout << playerTwo << " wins!" << std::endl; auto playAgainTemp = playAgain(); if (playAgainTemp == true ) { std::cout << "Swapping turns..." << std::endl; delay(1); gameBoard = initBoard(); ClearScreen(); swapTurn(turn); displayBoard(gameBoard, playerOneScore, playerTwoScore, turn); } else if (playAgainTemp == false ) { result.first = playerTwoScore; result.second = playerTwo; play = false; } } else if ( checkVictory(gameBoard) == false ) { if ( checkDraw(gameBoard) == true ) { ClearScreen(); displayBoard(gameBoard, playerOneScore, playerTwoScore, turn); std::cout << "The game is drawn." << std::endl; auto playAgainTemp = playAgain(); if (playAgainTemp == true ) { std::cout << "Swapping turns..." << std::endl; delay(1); gameBoard = initBoard(); ClearScreen(); swapTurn(turn); displayBoard(gameBoard, playerOneScore, playerTwoScore, turn); } else if (playAgainTemp == false ) { play = false; } } else if ( checkDraw(gameBoard) == false ) { swapTurn(turn); ClearScreen(); displayBoard(gameBoard, playerOneScore, playerTwoScore, turn); } } } } }