//Othello matchmaking code //06/10/2013 //Besim Avci #include #include #include #include #include #include #include #include #include //#include "time.h" #include "TeamA.h" //#include "Team2.h" #define TIMELIMIT 15 bool exceededTimeLimit(long limit, timeval start); int main(int argc, char * argv[]) { TeamA * playerOne = new TeamA(); TeamA * playerTwo = new TeamA(); //randomly assign as black or white srand((int)time(NULL)); int flipBlack = rand() % 2; int row = 0, col = 0; int consecutivepasses = 0; bool continueGame[2]; continueGame[0] = continueGame[1] = true; timeval start; if (flipBlack) { do { gettimeofday(&start, NULL); continueGame[0] = playerOne->play_square(row, col); if (exceededTimeLimit(TIMELIMIT, start)){ cout<<"Black timed out"<play_square(row, col); if (exceededTimeLimit(TIMELIMIT, start)){ cout<<"White timed out"<play_square(row, col); if (exceededTimeLimit(TIMELIMIT, start)){ cout<<"Black timed out"<play_square(row, col); if (exceededTimeLimit(TIMELIMIT, start)){ cout<<"White timed out"<score(); if(score == 0) cout << "Tie game." << endl; else if(score > 0) cout << "Black wins by " << score << endl; else if(score < 0) cout << "White wins by " << -score << endl; cout << "Press Enter to Exit" << endl; cin.ignore(); return 0; } bool exceededTimeLimit(long limit, timeval start){ timeval t; gettimeofday(&t, NULL); time_t timeElapsedInSeconds = (t.tv_sec - start.tv_sec); long total = timeElapsedInSeconds; return total >= limit; }