commit e2ef1fa590e6d7697331ee74400754290a595e60 Author: agsNeto20 <37492761+agsNeto20@users.noreply.github.com> Date: Wed May 11 17:44:45 2022 +0200 Add files via upload diff --git a/Connect4/Connect4.pro b/Connect4/Connect4.pro new file mode 100644 index 0000000..1ad2791 --- /dev/null +++ b/Connect4/Connect4.pro @@ -0,0 +1,17 @@ +TEMPLATE = app +CONFIG += console c++11 +CONFIG -= app_bundle +CONFIG -= qt + +SOURCES += \ + cboard.cpp \ + cmvm.cpp \ + cpvm.cpp \ + cpvp.cpp \ + main.cpp + +HEADERS += \ + cboard.h \ + cmvm.h \ + cpvm.h \ + cpvp.h diff --git a/Connect4/Connect4.pro.user b/Connect4/Connect4.pro.user new file mode 100644 index 0000000..00eafdf --- /dev/null +++ b/Connect4/Connect4.pro.user @@ -0,0 +1,322 @@ + + + + + + EnvironmentId + {f2964861-1c07-4053-861d-2df923f4a88c} + + + ProjectExplorer.Project.ActiveTarget + 0 + + + ProjectExplorer.Project.EditorSettings + + true + false + true + + Cpp + + CppGlobal + + + + QmlJS + + QmlJSGlobal + + + 2 + UTF-8 + false + 4 + false + 80 + true + true + 1 + false + true + false + 0 + true + true + 0 + 8 + true + false + 1 + true + true + true + *.md, *.MD, Makefile + false + true + + + + ProjectExplorer.Project.PluginSettings + + + true + false + true + true + true + true + + + 0 + true + + -fno-delayed-template-parsing + + true + Builtin.BuildSystem + + true + true + Builtin.DefaultTidyAndClazy + 2 + + + + true + + + + + ProjectExplorer.Project.Target.0 + + Desktop + Desktop Qt 5.15.2 MinGW 64-bit + Desktop Qt 5.15.2 MinGW 64-bit + qt.qt5.5152.win64_mingw81_kit + 0 + 0 + 0 + + 0 + C:\Users\André Neto\Dropbox\Ines e Andre\EDA\Connect4\build-Connect4-Desktop_Qt_5_15_2_MinGW_64_bit-Debug + C:/Users/André Neto/Dropbox/Ines e Andre/EDA/Connect4/build-Connect4-Desktop_Qt_5_15_2_MinGW_64_bit-Debug + + + true + QtProjectManager.QMakeBuildStep + false + + + + true + Qt4ProjectManager.MakeStep + + 2 + Build + Build + ProjectExplorer.BuildSteps.Build + + + + true + Qt4ProjectManager.MakeStep + clean + + 1 + Clean + Clean + ProjectExplorer.BuildSteps.Clean + + 2 + false + + + Debug + Qt4ProjectManager.Qt4BuildConfiguration + 2 + + + C:\Users\André Neto\Dropbox\Ines e Andre\EDA\Connect4\build-Connect4-Desktop_Qt_5_15_2_MinGW_64_bit-Release + C:/Users/André Neto/Dropbox/Ines e Andre/EDA/Connect4/build-Connect4-Desktop_Qt_5_15_2_MinGW_64_bit-Release + + + true + QtProjectManager.QMakeBuildStep + false + + + + true + Qt4ProjectManager.MakeStep + + 2 + Build + Build + ProjectExplorer.BuildSteps.Build + + + + true + Qt4ProjectManager.MakeStep + clean + + 1 + Clean + Clean + ProjectExplorer.BuildSteps.Clean + + 2 + false + + + Release + Qt4ProjectManager.Qt4BuildConfiguration + 0 + 0 + + + 0 + C:\Users\André Neto\Dropbox\Ines e Andre\EDA\Connect4\build-Connect4-Desktop_Qt_5_15_2_MinGW_64_bit-Profile + C:/Users/André Neto/Dropbox/Ines e Andre/EDA/Connect4/build-Connect4-Desktop_Qt_5_15_2_MinGW_64_bit-Profile + + + true + QtProjectManager.QMakeBuildStep + false + + + + true + Qt4ProjectManager.MakeStep + + 2 + Build + Build + ProjectExplorer.BuildSteps.Build + + + + true + Qt4ProjectManager.MakeStep + clean + + 1 + Clean + Clean + ProjectExplorer.BuildSteps.Clean + + 2 + false + + + Profile + Qt4ProjectManager.Qt4BuildConfiguration + 0 + 0 + 0 + + 3 + + + 0 + Deploy + Deploy + ProjectExplorer.BuildSteps.Deploy + + 1 + + false + ProjectExplorer.DefaultDeployConfiguration + + 1 + + dwarf + + cpu-cycles + + + 250 + + -e + cpu-cycles + --call-graph + dwarf,4096 + -F + 250 + + -F + true + 4096 + false + false + 1000 + + true + + + false + false + false + false + true + 0.01 + 10 + true + kcachegrind + 1 + + 25 + + 1 + true + false + true + + valgrind + + 0 + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + 10 + 11 + 12 + 13 + 14 + + + 2 + + Qt4ProjectManager.Qt4RunConfiguration:C:/Users/André Neto/Dropbox/Ines e Andre/EDA/Connect4/Connect4/Connect4.pro + C:/Users/André Neto/Dropbox/Ines e Andre/EDA/Connect4/Connect4/Connect4.pro + false + true + true + false + true + true + C:/Users/André Neto/Dropbox/Ines e Andre/EDA/Connect4/build-Connect4-Desktop_Qt_5_15_2_MinGW_64_bit-Debug + + 1 + + + + ProjectExplorer.Project.TargetCount + 1 + + + ProjectExplorer.Project.Updater.FileVersion + 22 + + + Version + 22 + + diff --git a/Connect4/Connect4.pro.user.8c2f6f0 b/Connect4/Connect4.pro.user.8c2f6f0 new file mode 100644 index 0000000..2ebbf33 --- /dev/null +++ b/Connect4/Connect4.pro.user.8c2f6f0 @@ -0,0 +1,322 @@ + + + + + + EnvironmentId + {8c2f6f0b-020e-4c89-9d71-737524f37114} + + + ProjectExplorer.Project.ActiveTarget + 0 + + + ProjectExplorer.Project.EditorSettings + + true + false + true + + Cpp + + CppGlobal + + + + QmlJS + + QmlJSGlobal + + + 2 + UTF-8 + false + 4 + false + 80 + true + true + 1 + true + false + 0 + true + true + 0 + 8 + true + 1 + true + true + true + *.md, *.MD, Makefile + false + true + + + + ProjectExplorer.Project.PluginSettings + + + true + true + true + true + true + + + 0 + true + + -fno-delayed-template-parsing + + true + Builtin.Questionable + + true + true + Builtin.DefaultTidyAndClazy + 4 + + + + true + + + + + ProjectExplorer.Project.Target.0 + + Desktop + Desktop Qt 5.15.2 MinGW 32-bit + Desktop Qt 5.15.2 MinGW 32-bit + qt.qt5.5152.win32_mingw81_kit + 0 + 0 + 0 + + 0 + D:\Dropbox\Ines e Andre\EDA\Final\build-Connect4-Desktop_Qt_5_15_2_MinGW_32_bit-Debug + D:/Dropbox/Ines e Andre/EDA/Final/build-Connect4-Desktop_Qt_5_15_2_MinGW_32_bit-Debug + + + true + QtProjectManager.QMakeBuildStep + + false + + + + true + Qt4ProjectManager.MakeStep + + 2 + Build + Build + ProjectExplorer.BuildSteps.Build + + + + true + Qt4ProjectManager.MakeStep + clean + + 1 + Clean + Clean + ProjectExplorer.BuildSteps.Clean + + 2 + false + + + Debug + Qt4ProjectManager.Qt4BuildConfiguration + 2 + 0 + + + D:\Dropbox\Ines e Andre\EDA\Final\build-Connect4-Desktop_Qt_5_15_2_MinGW_32_bit-Release + D:/Dropbox/Ines e Andre/EDA/Final/build-Connect4-Desktop_Qt_5_15_2_MinGW_32_bit-Release + + + true + QtProjectManager.QMakeBuildStep + + false + + + + true + Qt4ProjectManager.MakeStep + + 2 + Build + Build + ProjectExplorer.BuildSteps.Build + + + + true + Qt4ProjectManager.MakeStep + clean + + 1 + Clean + Clean + ProjectExplorer.BuildSteps.Clean + + 2 + false + + + Release + Qt4ProjectManager.Qt4BuildConfiguration + 0 + 0 + 0 + + + 0 + D:\Dropbox\Ines e Andre\EDA\Final\build-Connect4-Desktop_Qt_5_15_2_MinGW_32_bit-Profile + D:/Dropbox/Ines e Andre/EDA/Final/build-Connect4-Desktop_Qt_5_15_2_MinGW_32_bit-Profile + + + true + QtProjectManager.QMakeBuildStep + + false + + + + true + Qt4ProjectManager.MakeStep + + 2 + Build + Build + ProjectExplorer.BuildSteps.Build + + + + true + Qt4ProjectManager.MakeStep + clean + + 1 + Clean + Clean + ProjectExplorer.BuildSteps.Clean + + 2 + false + + + Profile + Qt4ProjectManager.Qt4BuildConfiguration + 0 + 0 + 0 + 0 + + 3 + + + 0 + Deploy + Deploy + ProjectExplorer.BuildSteps.Deploy + + 1 + + false + ProjectExplorer.DefaultDeployConfiguration + + 1 + + dwarf + + cpu-cycles + + + 250 + + -e + cpu-cycles + --call-graph + dwarf,4096 + -F + 250 + + -F + true + 4096 + false + false + 1000 + + true + + false + false + false + false + true + 0.01 + 10 + true + kcachegrind + 1 + 25 + + 1 + true + false + true + valgrind + + 0 + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + 10 + 11 + 12 + 13 + 14 + + + 2 + + Qt4ProjectManager.Qt4RunConfiguration:D:/Dropbox/Ines e Andre/EDA/Final/Connect4/Connect4.pro + D:/Dropbox/Ines e Andre/EDA/Final/Connect4/Connect4.pro + false + true + true + false + true + true + D:/Dropbox/Ines e Andre/EDA/Final/build-Connect4-Desktop_Qt_5_15_2_MinGW_32_bit-Debug + + 1 + + + + ProjectExplorer.Project.TargetCount + 1 + + + ProjectExplorer.Project.Updater.FileVersion + 22 + + + Version + 22 + + diff --git a/Connect4/cboard.cpp b/Connect4/cboard.cpp new file mode 100644 index 0000000..1e21005 --- /dev/null +++ b/Connect4/cboard.cpp @@ -0,0 +1,173 @@ +#include "cboard.h" + +//============================================================================= + +CBoard::CBoard() // constructor +{ + //Dynamically allocate memory for 3D array + boards = new char**[SIZE]; + for (int s = 0; s < SIZE; s++){ + boards[s] = new char*[MAX_R]; + for (int r = 0; r < MAX_R; r++) + boards[s][r] = new char[MAX_C]; + } + // assign value ' ' to the allocated memory + for (int s = 0; s < SIZE; s++) + for (int c = 0; c < MAX_C; c++) + for (int r = 0; r < MAX_R; r++) + boards[s][r][c] = ' '; + turn = 0; +} +CBoard::~CBoard() // destructor +{ + // deallocate 3D array + for (int s = 0; s < SIZE; s++){ + for (int r = 0; r < MAX_R; r++) + delete []boards[s][r]; + delete []boards[s]; + } + delete []boards; +} + +//============================================================================= + +// returns closest free (' ') row of col to the bottom, if not, -1 +int CBoard::getRow(int col) const{ + for(int r = MAX_R-1; r >= 0; r--) + if(boards[turn][r][col] == ' ') + return r; + return -1; +} + +//============================================================================= + +// puts player in the col and increments turn +void CBoard::playPiece(int col, char player) { + for(int r = 0; r < MAX_R; r++) + for(int c = 0; c < MAX_C; c++) + boards[turn+1][r][c] = boards[turn][r][c]; + boards[++turn][getRow(col)][col] = player; +} +// undoes n turns +void CBoard::undoPiece(int undo){ + turn -= undo; +} +// advances n turns +void CBoard::advancePiece(int adv){ + turn += adv; +} + +//============================================================================= + +// gets the player who played on that col, checks for a win +bool CBoard::checkWin(int col, int num) const{ + int row = getRow(col)+1; + char player = boards[turn][row][col]; + + // checks horizontal + for (int c = 0, count = 0; c < MAX_C; c++){ + if (boards[turn][row][c] == player) + count ++; + else count = 0; + + if (count == num) + return true; + } + + // checks vertical + for (int r = 0, count = 0; r < MAX_R; r++){ + if (boards[turn][r][col] == player) + count ++; + else count = 0; + + if (count == num) + return true; + } + + // checks diagonal NE + // left half + for(int i=3, count=0; i <= 5; i++, count=0) + for(int r=i, c=0; r >= 0; r--, c++){ + if (boards[turn][r][c] == player) count++; + else count = 0; + + if (count == num) return true; + } + // right half + for(int i=2, count=0; i >= 0; i--, count=0) + for(int r=i, c=6; r <= 5; r++, c--){ + if (boards[turn][r][c] == player) count++; + else count = 0; + + if (count == num) return true; + } + + + // checks diagonal SE + // left half + for(int i=3, count=0; i <= 5 ; i++, count=0) + for(int c=i, r=5; c >= 0 ; c--, r--){ + if (boards[turn][r][c] == player) count++; + else count = 0; + + if (count == num) return true; + } + // right half + for(int i=3, count=0; i > 0; i--, count=0) + for(int c=i, r=0; c <= 6 ; c++, r++){ + if (boards[turn][r][c] == player) count++; + else count = 0; + + if (count == num) return true; + } + + return false; +} +// simulate a play and checks if it's a win +bool CBoard::simulateWin(int col, char player){ + playPiece(col, player); + bool win = checkWin(col, 4); + undoPiece(1); + return win; +} + +//============================================================================= + +// prints board all fancy +void CBoard::printBoard() const{ + HANDLE hConsole = GetStdHandle(STD_OUTPUT_HANDLE); + SetConsoleTextAttribute(hConsole, 15); + + cout << "| 1 | 2 | 3 | 4 | 5 | 6 | 7 |" << endl; + for(int r = 0; r < MAX_R; r++){ + for(int c = 0; c < MAX_C; c++){ + cout << "| "; + switch (boards[turn][r][c]){ + case '0': SetConsoleTextAttribute(hConsole, 4); break; + case 'O': SetConsoleTextAttribute(hConsole, 6); break; + } + cout << boards[turn][r][c] << " "; + SetConsoleTextAttribute(hConsole, 15); + } + cout << "|" << endl; + } +} +// TODO +void CBoard::printBoardAdvanced() const{ + + for(int header = 0; header <= turn; header++) + cout << "| 1 | 2 | 3 | 4 | 5 | 6 | 7 | " ; + cout << endl; + + for(int r = 0 ; r < MAX_R; r++){ + for(int s = turn; s >= 0; s--){ + for(int c = 0 ; c < MAX_C; c++) + cout << "| " << boards[s][r][c] << " "; + cout << "| "; + } + cout << endl; + } + cout << endl; +} + +//============================================================================= diff --git a/Connect4/cboard.h b/Connect4/cboard.h new file mode 100644 index 0000000..09ebaab --- /dev/null +++ b/Connect4/cboard.h @@ -0,0 +1,39 @@ +#include +#include +#include +using namespace std; + +#ifndef CBOARD_H +#define CBOARD_H + +class CBoard{ + friend class CPvM; + friend class CPvP; + friend class CMvM; + +private: + char ***boards; + int turn; + +public: + constexpr static const int MAX_C = 7; + constexpr static const int MAX_R = 6; + constexpr static const int SIZE = MAX_R*MAX_C + 1; + + CBoard(); + ~CBoard(); + + int getRow(int) const; + + void playPiece(int,char); + void undoPiece(int); + void advancePiece(int); + + bool checkWin(int,int) const; + bool simulateWin(int,char); + + void printBoard() const; + void printBoardAdvanced() const; +}; + +#endif // CBOARD_H diff --git a/Connect4/cmvm.cpp b/Connect4/cmvm.cpp new file mode 100644 index 0000000..8474bce --- /dev/null +++ b/Connect4/cmvm.cpp @@ -0,0 +1,243 @@ +#include "cmvm.h" + +//============================================================================= + +CMvM::CMvM(int dif1, int dif2, char starter) // constructor +{ + board = new CBoard(); + current_player = starter; + difficulty1 = dif1; + difficulty2 = dif2; +} +CMvM::~CMvM() // destructor +{ delete board; } + +//============================================================================= + +void CMvM::playGame() // main method +{ + while(board->turn+1 < CBoard::SIZE){ + showGame(); + saveGame(); + if(board->checkWin(computerMakePlay(),4)) + break; + switchPlayer(); + system("pause"); + + if(board->turn+1 == CBoard::SIZE) + current_player = 'T'; // tie/draw + } + clearFile(); + showGame(); + gameOver(); +} +void CMvM::gameOver() // credits +{ + HANDLE hConsole = GetStdHandle(STD_OUTPUT_HANDLE); + switch (current_player) { + case '0': + SetConsoleTextAttribute(hConsole, 79); + cout << endl << "Red won!"; break; + case 'O': + SetConsoleTextAttribute(hConsole, 111); + cout << endl << "Yellow won!"; break; + case 'T': cout << endl << "It's a tie!"; + } + + SetConsoleTextAttribute(hConsole, 15); + cout << endl << endl << "THANKS FOR PLAYING!" << endl + << "Game developed by:" << endl + << "Ines Ferreira & Andre Neto" << endl << endl; + system("pause"); +} + +//============================================================================= + +void CMvM::showGame() const // machine + difficulty + turn + board +{ + system("cls"); + switch(current_player){ + case 'O': + cout << "Machine 1's turn "; + + switch (difficulty1){ + case 1: cout << "(Easy)"; break; + case 2: cout << "(Medium)"; break; + case 3: cout << "(Hard)"; break; + case 4: cout << "(Extreme)"; break; + }break; + + case '0': + cout << "Machine 2's turn "; + + switch (difficulty2){ + case 1: cout << "(Easy)"; break; + case 2: cout << "(Medium)"; break; + case 3: cout << "(Hard)"; break; + case 4: cout << "(Extreme)"; break; + }break; + } + + cout << endl << "Turn: " << board->turn << endl; + + board->printBoard(); +} +void CMvM::switchPlayer() // switches between players +{ + if (current_player == 'O') + current_player = '0'; + else + current_player = 'O'; +} +int CMvM::computerMakePlay() // machine's turn +{ + + int play = -1; + int dif=0; + switch(current_player){ + case 'O': dif=difficulty1;break; + case '0': dif=difficulty2; + } + + switch (dif){ + case 1: // easy + play = randomPlay(); + break; + + case 2: // medium + play = winNextPlay(); + if (play == -1) + play = randomPlay(); + break; + + case 3: // hard + play = winNextPlay(); + if (play == -1) + play = defendNextPlay(); + if (play == -1) + play = randomPlay(); + break; + + case 4: // extreme + play = winNextPlay(); + if (play == -1) + play = defendNextPlay(); + if (play == -1) + play = bestPlay(); + break; + } + + board->playPiece(play, current_player); + return play; +} + +//============================================================================= + +int CMvM::randomPlay() // return a valid random play +{ + int play; + do{ + srand (time(NULL)); + play = rand() % 7; + } while (board->getRow(play) == -1); + return play; +} +int CMvM::winNextPlay() // return winning play, if not -1 +{ + for (int col=0; colgetRow(col) != -1) + if(board->simulateWin(col, '0')) + return col; + return -1; +} +int CMvM::defendNextPlay() // return defending play, if not -1 +{ + for (int col=0; colgetRow(col) != -1) + if(board->simulateWin(col, 'O')) + return col; + return -1; +} +int CMvM::bestPlay(){ + + int score[7] = {0,0,0,0,0,0,0}; + + for (int col = 0; col < CBoard::MAX_C; col++){ + if (board->getRow(col) != -1){ + board->playPiece(col, '0'); + if (col == 0 || col == 6) score[col]--; + if (col == 2 || col == 4) score[col]++; + if (col == 3) score[col] += 2; + for (int s = 2; s < 4; s++) + score[col] += s*board->checkWin(col,s); + board->undoPiece(1); + } + } + + int max = score[0]; + int maxIndex = 0; + + for (int i = 1; i < 7; i++) { + if (score[i] > max) { + maxIndex = i; + max = score[i]; + } + } + + return maxIndex; +} + +//============================================================================= + +void CMvM::saveGame() const // saves game in case of unexpected shutdown +{ + ofstream WriteFile("savedgame_mvm.txt"); + for (int t = 0; t < CBoard::SIZE; t++) + for (int r = 0; r < CBoard::MAX_R; r++) + for (int c = 0; c < CBoard::MAX_C; c++) + WriteFile << board->boards[t][r][c]; + + WriteFile << endl << board->turn + << endl << current_player + << endl << difficulty1 + << endl << difficulty2; + + WriteFile.close(); +} +void CMvM::clearFile () const // clears saved game after its over +{ + ofstream MyFile("savedgame_mvm.txt"); + MyFile.close(); +} +bool CMvM::loadGame() // resume game, returns false if there is no game to resume +{ + + ifstream MyReadFile("savedgame_mvm.txt"); + if(MyReadFile.peek() == ifstream::traits_type::eof()) + return false; // checks if its empty + + string tmpString; + getline(MyReadFile, tmpString); // gets board + int i = 0; + for(int t = 0; t < CBoard::SIZE; t++) + for(int r = 0; r < CBoard::MAX_R; r++) + for(int c = 0; c < CBoard::MAX_C; c++) + board->boards[t][r][c] = tmpString[i++]; + + getline(MyReadFile, tmpString); // gets turn + board->turn = stoi(tmpString); + + getline(MyReadFile, tmpString); // gets current_player + current_player = tmpString[0]; + + getline(MyReadFile, tmpString); // gets player name1 + difficulty1 = stoi(tmpString); + + getline(MyReadFile, tmpString); // gets player name2 + difficulty2 = stoi(tmpString); + + MyReadFile.close(); + return true; // successful +} + +//============================================================================= diff --git a/Connect4/cmvm.h b/Connect4/cmvm.h new file mode 100644 index 0000000..f7490e5 --- /dev/null +++ b/Connect4/cmvm.h @@ -0,0 +1,47 @@ +#include +#include +#include + +#ifndef CMVM_H +#define CMVM_H + +#include "cboard.h" +using namespace std; + +class CMvM +{ +private: + CBoard *board; + char current_player; + int difficulty1; + int difficulty2; + +public: + CMvM(int = 1, int = 1, char = 'O'); + ~CMvM(); + + // GAME + void playGame(); // main method + void gameOver(); // roll the credits + void showGame() const; // show game events + void switchPlayer(); // switch between players + + // PLAYERS MECHANINCS + int computerMakePlay(); + + // ALGORITHMS + int randomPlay(); // returns random play + int winNextPlay(); // returns next win move, if not, -1 + int defendNextPlay() ; // returns next defensive move, if not, -1 + int bestPlay(); // returns the best play possible + + // FILES + void saveGame() const; // saves game into file + bool loadGame(); // loads game from file (if any) + void clearFile() const; // clears file + + + +}; + +#endif // CMVM_H diff --git a/Connect4/cpvm.cpp b/Connect4/cpvm.cpp new file mode 100644 index 0000000..2a69a46 --- /dev/null +++ b/Connect4/cpvm.cpp @@ -0,0 +1,364 @@ +#include "cpvm.h" + +//============================================================================= + +CPvM::CPvM(string name, int dif, char starter) // constructor +{ + board = new CBoard(); + current_player = starter; + player_name = name; + difficulty = dif; +} +CPvM::~CPvM() // destructor +{ delete board; } + +//============================================================================= + +void CPvM::playGame() // main method +{ + while(board->turn+1 < board->SIZE){ + showGame(); + saveGame(); + if(board->checkWin(makePlay(),4)) + break; + switchPlayer(); + + if(board->turn+1 == board->SIZE) + current_player = 'T'; // tie/draw + } + clearFile(); + showGame(); + gameOver(); +} +void CPvM::gameOver() // credits +{ + HANDLE hConsole = GetStdHandle(STD_OUTPUT_HANDLE); + switch (current_player) { + case '0': + SetConsoleTextAttribute(hConsole, 79); + cout << endl << "Red won!"; + saveScore(false); break; + case 'O': + SetConsoleTextAttribute(hConsole, 111); + cout << endl << "Yellow won!"; + saveScore(true); break; + case 'T': cout << endl << "It's a tie!"; + } + + SetConsoleTextAttribute(hConsole, 15); + cout << endl << endl << "THANKS FOR PLAYING!" << endl + << "Game developed by:" << endl + << "Ines Ferreira & Andre Neto" << endl << endl; + system("pause"); +} +void CPvM::showGame() const // shows player + turn + board +{ + system("cls"); + cout << "Difficulty: "; + switch (difficulty) { + case 1: cout << "Easy"; break; + case 2: cout << "Medium"; break; + case 3: cout << "Hard"; break; + case 4: cout << "Extreme"; break; + } + cout << endl << "Turn " << board->turn << endl; + board->printBoard(); +} +void CPvM::switchPlayer() // switches between players +{ + if (current_player == 'O') + current_player = '0'; + else + current_player = 'O'; +} + +//============================================================================= + +int CPvM::makePlay() // decides who makes the play +{ + int play; + switch (current_player){ + case 'O': play = playerMakePlay(); break; + case '0': play = computerMakePlay(); break; + } + board->playPiece(play, current_player); + return play; +} +int CPvM::playerMakePlay() // player's turn +{ + int play; + char cplay; + int t = board->turn; + do{ + cout << "Pick a collumn [1..7]: "; + cin >> cplay; + if (cplay == '-'){ + if(board->turn >= 2){ + board->undoPiece(2); + showGame(); + } + } + if (cplay == '+'){ + if(board->turn < t){ + board->advancePiece(2); + showGame(); + } + } + if (cplay == '0'){ + exit(0); + } + + play = (int)cplay - 48 - 1; + }while (play >= CBoard::MAX_C || play < 0 || board->getRow(play) == -1); + + return play; +} +int CPvM::computerMakePlay() // machine's turn +{ + int play = -1; + + switch (difficulty){ + case 1: // easy + play = randomPlay(); + break; + + case 2: // medium + play = winNextPlay(); + break; + + case 3: // hard + play = winNextPlay(); + if (play == -1) + play = defendNextPlay(); + if (play == -1) + play = randomPlay(); + break; + + case 4: // extreme + play = winNextPlay(); + if (play == -1) + play = defendNextPlay(); + if (play == -1) + play = bestPlay(); + break; + } + + return play; +} + +//============================================================================= + +int CPvM::randomPlay() // return a valid random play +{ + int play; + do{ + srand (time(NULL)); + play = rand() % 7; + } while (board->getRow(play) == -1); + return play; +} +int CPvM::winNextPlay() // return winning play, if not -1 +{ + for (int col=0; colgetRow(col) != -1) + if(board->simulateWin(col, '0')) + return col; + return -1; +} +int CPvM::defendNextPlay() // return defending play, if not -1 +{ + for (int col=0; colgetRow(col) != -1) + if(board->simulateWin(col, 'O')) + return col; + return -1; +} +int CPvM::bestPlay(){ + + int score[7] = {0,0,0,0,0,0,0}; + + for (int col = 0; col < CBoard::MAX_C; col++){ + if (board->getRow(col) != -1){ + board->playPiece(col, '0'); + if (col == 0 || col == 6) score[col] -= 3; + if (col == 1 || col == 5) score[col] -= 2; + if (col == 2 || col == 4) score[col] += 0; + if (col == 3) score[col] += 1; + for (int s = 1; s < 4; s++) + score[col] += s*board->checkWin(col,s); + board->undoPiece(1); + } + } + + int max = score[0]; + int maxIndex = 0; + + for (int i = 1; i < 7; i++) { + if (score[i] > max) { + maxIndex = i; + max = score[i]; + } + } + return maxIndex; +} + +//============================================================================= + +void CPvM::saveGame() const // saves game in case of unexpected shutdown +{ + ofstream WriteFile("savedgame_pvm.txt"); + for (int t = 0; t < CBoard::SIZE; t++) + for (int r = 0; r < CBoard::MAX_R; r++) + for (int c = 0; c < CBoard::MAX_C; c++) + WriteFile << board->boards[t][r][c]; + + WriteFile << endl << board->turn + << endl << current_player + << endl << player_name + << endl << difficulty; + + WriteFile.close(); +} +void CPvM::clearFile () const // clears saved game after its over +{ + ofstream MyFile("savedgame_pvm.txt"); + MyFile.close(); +} +bool CPvM::loadGame() // resume game, return false if no game to resume +{ + + ifstream MyReadFile("savedgame_pvm.txt"); + if(MyReadFile.peek() == ifstream::traits_type::eof()) + return false; // checks if its empty + + string tmpString; + getline(MyReadFile, tmpString); // gets board + int i = 0; + for(int t = 0; t < CBoard::SIZE; t++) + for(int r = 0; r < CBoard::MAX_R; r++) + for(int c = 0; c < CBoard::MAX_C; c++) + board->boards[t][r][c] = tmpString[i++]; + + getline(MyReadFile, tmpString); // gets turn + board->turn = stoi(tmpString); + + getline(MyReadFile, tmpString); // gets current_player + current_player = tmpString[0]; + + getline(MyReadFile, tmpString); // gets player + player_name = tmpString; + + getline(MyReadFile, tmpString); // gets difficulty + difficulty = stoi(tmpString); + + MyReadFile.close(); + return true; // successful +} + +//============================================================================= + +struct CPvM::stats // struct to recieve all stats from file +{ + string name; + int win; + int loss; +}; +void CPvM::swap(stats *xp, stats *yp) +{ + stats temp = *xp; + *xp = *yp; + *yp = temp; +} +void CPvM::selectionSort(stats arr[], int n) // score = wins - losses +{ + for(int i = 0; i < n-1; i++){ + int min_idx = i; + for (int j = i+1; j < n; j++) + if ((arr[j].win - arr[j].loss) > (arr[min_idx].win - arr[min_idx].loss)) + min_idx = j; + swap(&arr[min_idx], &arr[i]); + } +} +void CPvM::saveScore(bool is_win) // saves player score to leaderboards +{ + + ifstream ReadFile("leaderboard_pvm.txt"); + string line; + int total=0; + + getline(ReadFile, line); + if(ReadFile.peek() == ifstream::traits_type::eof()){} + //total = 0; // checks if its empty + else + total = stoi (line); // total number of players registred + + stats all[total+1]; + all[total].win = 0; + all[total].loss = 0; + int found = -1; + + // from file to struct stats + for (int i = 0; i < total; i++){ + getline(ReadFile, line); + all[i].name = line; + getline(ReadFile, line); + all[i].win = stoi(line); + getline(ReadFile, line); + all[i].loss = stoi(line); + //ReadFile >> all[i].win >> all[i].loss; + // searches for player name in files + if (all[i].name == player_name) + found = i; + } + ReadFile.close(); + + // if player name already exists + if (found != -1){ + if (is_win) all[found].win++; + else all[found].loss++; + } + + // if player name doesn't exists + else { + all[total].name = player_name; + if (is_win) all[total].win++; + else all[total].loss++; + total++; + } + + selectionSort(all, total); + // put ordered leaderboard in file + ofstream WriteFile("leaderboard_pvm.txt"); + WriteFile << total; + for(int i = 0; i < total; i++) + WriteFile << endl << all[i].name << endl << all[i].win << endl << all[i].loss; + WriteFile.close(); + +} +void CPvM::leaderboard() const // show top 10 +{ + string line; + ifstream ReadFile("leaderboard_pvm.txt"); + if(ReadFile.peek() == ifstream::traits_type::eof()) + return; // checks if its empty + getline(ReadFile, line); + + int n_players, total_players = stoi (line); + if (total_players < 10) n_players = total_players; + else n_players = 10; + + cout << " --PLAYER VS MACHINE LEADERBOARD--" << endl << endl; + cout << "Top 10" << setw(20) << "Name" << setw(10) << "Wins" << setw(10) << "Losses" << endl; + for (int i = 0; i < n_players; i++){ + getline(ReadFile, line); + cout << setw(6) << i+1 << setw(20) << line; + getline(ReadFile, line); + cout << setw(10) << line; + getline(ReadFile, line); + cout << setw(10) << line << endl; + } + cout << endl; + ReadFile.close(); +} + +//============================================================================= diff --git a/Connect4/cpvm.h b/Connect4/cpvm.h new file mode 100644 index 0000000..1b9630f --- /dev/null +++ b/Connect4/cpvm.h @@ -0,0 +1,52 @@ +#include +#include +#include +#include + +#ifndef CPVM_H +#define CPVM_H + +#include "cboard.h" +using namespace std; + +class CPvM +{ +private: + CBoard *board; + string player_name; + char current_player; + int difficulty; + +public: + CPvM(string = "Guest", int = 1, char = 'O'); + ~CPvM(); + + // GAME + void playGame(); // main method + void gameOver(); // roll the credits + void showGame() const; // show game events + void switchPlayer(); // switch between players + + // PLAYERS MECHANINCS + int makePlay(); // calls playerMakePlay() or computerMakePlay() + int playerMakePlay(); // returns & plays a valid move from player + int computerMakePlay(); // returns & plays a valid move from computer + + // ALGORITHMS + int randomPlay(); // returns random play + int winNextPlay(); // returns next win move, if not, -1 + int defendNextPlay(); // returns next defensive move, if not, -1 + int bestPlay(); // returns the best play possible + + // FILES + void saveGame()const; // saves game into file + void clearFile() const; // clears file + bool loadGame(); // loads game from file (if any) + + struct stats; + void swap(stats *, stats *); + void selectionSort(stats [], int); + void saveScore(bool); + void leaderboard() const;}; + +#endif // CPVM_H diff --git a/Connect4/cpvp.cpp b/Connect4/cpvp.cpp new file mode 100644 index 0000000..32438b3 --- /dev/null +++ b/Connect4/cpvp.cpp @@ -0,0 +1,271 @@ +#include "cpvp.h" + +//============================================================================= + +CPvP::CPvP(string name1, string name2, char starter) // constructor +{ + board = new CBoard(); + player_name1 = name1; // 'U' + player_name2 = name2; // 'C' + current_player = starter; +} +CPvP::~CPvP() // destructor +{ delete board; } + +//============================================================================= + +void CPvP::playGame() // main method +{ + while(board->turn+1 < CBoard::SIZE){ + showGame(); + saveGame(); + if(board->checkWin(playerMakePlay(),4)) + break; + switchPlayer(); + + if(board->turn+1 == board->SIZE) + current_player = 'T'; // tie/draw + } + clearFile(); + showGame(); + gameOver(); +} +void CPvP::gameOver() // credits +{ + HANDLE hConsole = GetStdHandle(STD_OUTPUT_HANDLE); + switch (current_player) { + case 'O': + SetConsoleTextAttribute(hConsole, 111); + cout << endl << "Yellow won!"; + saveScore(false, player_name2); + saveScore(true, player_name1); + break; + case '0': + SetConsoleTextAttribute(hConsole, 79); + cout << endl << "Red won!"; + saveScore(true, player_name2); + saveScore(false, player_name1); + break; + + case 'T': cout << endl << "It's a tie!"; + } + + SetConsoleTextAttribute(hConsole, 15); + cout << endl << endl << "THANKS FOR PLAYING!" << endl + << "Game developed by:" << endl + << "Ines Ferreira & Andre Neto" << endl << endl; + system("pause"); +} + +//============================================================================= + +void CPvP::showGame() // shows player + turn + board +{ + system("cls"); + switch(current_player){ + case 'O': cout << player_name1 << "'s turn" + << endl << "Turn " << board->turn << endl; break; + case '0': cout << player_name2 << "'s turn" + << endl << "Turn " << board->turn << endl; + } + + board->printBoard(); +} +void CPvP::switchPlayer() // switches between players +{ + if (current_player == 'O') + current_player = '0'; + else + current_player = 'O'; +} +int CPvP::playerMakePlay(){ + int play; + char cplay; + int t = board->turn; + do{ + cout << "Pick a collumn [1..7]: "; + cin >> cplay; + if (cplay == '-'){ + if(board->turn >= 1){ + board->undoPiece(1); + switchPlayer(); + showGame(); + } + } + if (cplay == '+'){ + if(board->turn < t){ + board->advancePiece(1); + switchPlayer(); + showGame(); + } + } + if (cplay == '0'){ + exit(0); + } + + play = (int)cplay - 48 - 1; + }while (play >= CBoard::MAX_C || play < 0 || board->getRow(play) == -1); + + board->playPiece(play, current_player); + return play; +} + +//============================================================================= + +void CPvP::saveGame() // saves game in case of unexpected shutdown +{ + ofstream WriteFile("savedgame_pvp.txt"); + for (int t = 0; t < CBoard::SIZE; t++) + for (int r = 0; r < CBoard::MAX_R; r++) + for (int c = 0; c < CBoard::MAX_C; c++) + WriteFile << board->boards[t][r][c]; + + WriteFile << endl << board->turn + << endl << current_player + << endl << player_name1 + << endl << player_name2; + + WriteFile.close(); +} +void CPvP::clearFile () const // clears saved game after its over +{ + ofstream MyFile("savedgame_pvp.txt"); + MyFile.close(); +} +bool CPvP::loadGame() // resume game, returns false if there is no game to resume +{ + + ifstream MyReadFile("savedgame_pvp.txt"); + if(MyReadFile.peek() == ifstream::traits_type::eof()) + return false; // checks if its empty + + string tmpString; + getline(MyReadFile, tmpString); // gets board + int i = 0; + for(int t = 0; t < CBoard::SIZE; t++) + for(int r = 0; r < CBoard::MAX_R; r++) + for(int c = 0; c < CBoard::MAX_C; c++) + board->boards[t][r][c] = tmpString[i++]; + + getline(MyReadFile, tmpString); // gets turn + board->turn = stoi(tmpString); + + getline(MyReadFile, tmpString); // gets current_player + current_player = tmpString[0]; + + getline(MyReadFile, tmpString); // gets player name1 + player_name1 = tmpString; + + getline(MyReadFile, tmpString); // gets player name2 + player_name2 = tmpString; + + MyReadFile.close(); + return true; // successful +} + +//============================================================================= + +struct CPvP::stats{ + string name; + int win; + int loss; +}; +void CPvP::swap(stats *xp, stats *yp) // selection sort: score = wins - losses +{ + stats temp = *xp; + *xp = *yp; + *yp = temp; +} +void CPvP::selectionSort(stats arr[], int n){ + for(int i = 0; i < n-1; i++){ + int min_idx = i; + for (int j = i+1; j < n; j++) + if ((arr[j].win - arr[j].loss) > (arr[min_idx].win - arr[min_idx].loss)) + min_idx = j; + swap(&arr[min_idx], &arr[i]); + } +} +void CPvP::saveScore(bool is_win, string name) // saves player score to player vs machine leaderboards +{ + + ifstream ReadFile("leaderboard_pvp.txt"); + string line; + int total=0; + + getline(ReadFile, line); + if(ReadFile.peek() == ifstream::traits_type::eof()){} + //total = 0; // checks if its empty + else + total = stoi (line); // total number of players registred + + stats all[total+1]; + all[total].win = 0; + all[total].loss = 0; + int found = -1; + + // from file to struct stats + for (int i = 0; i < total; i++){ + getline(ReadFile, line); + all[i].name = line; + getline(ReadFile, line); + all[i].win = stoi(line); + getline(ReadFile, line); + all[i].loss = stoi(line); + //ReadFile >> all[i].win >> all[i].loss; + // searches for player name in files + if (all[i].name == name) + found = i; + } + ReadFile.close(); + + // if player name already exists + if (found != -1){ + if (is_win) all[found].win++; + else all[found].loss++; + } + + // if player name doesn't exists + else { + all[total].name = name; + if (is_win) all[total].win++; + else all[total].loss++; + total++; + } + + selectionSort(all, total); + // put ordered leaderboard in file + ofstream WriteFile("leaderboard_pvp.txt"); + WriteFile << total; + for(int i = 0; i < total; i++) + WriteFile << endl << all[i].name << endl << all[i].win << endl << all[i].loss; + WriteFile.close(); + +} +void CPvP::leaderboard() const // show top 10 +{ + + string line; + ifstream ReadFile("leaderboard_pvp.txt"); + if(ReadFile.peek() == ifstream::traits_type::eof()) + return; // checks if its empty + getline(ReadFile, line); + + int n_players, total_players = stoi (line); + if (total_players < 10) n_players = total_players; + else n_players = 10; + + cout << " --PLAYER VS PLAYER LEADERBOARD--" << endl << endl; + cout << "Top 10" << setw(20) << "Name" << setw(10) << "Wins" << setw(10) << "Losses" << endl; + for (int i = 0; i < n_players; i++){ + getline(ReadFile, line); + cout << setw(6) << i+1 << setw(20) << line; + getline(ReadFile, line); + cout << setw(10) << line; + getline(ReadFile, line); + cout << setw(10) << line << endl; + } + cout << endl; + ReadFile.close(); +} + +//============================================================================= diff --git a/Connect4/cpvp.h b/Connect4/cpvp.h new file mode 100644 index 0000000..eeb655f --- /dev/null +++ b/Connect4/cpvp.h @@ -0,0 +1,45 @@ +#include +#include +#include + +#ifndef CPVP_H +#define CPVP_H + +#include "cboard.h" +using namespace std; + +class CPvP +{ +private: + CBoard *board; + string player_name1; + string player_name2; + char current_player; + +public: + CPvP(string = "Guest1", string = "Guest2", char = 'O'); + ~CPvP(); + + // GAME + void playGame(); // main method + void gameOver(); // roll the credits + void showGame(); // show player turn, board + void switchPlayer(); // switch between players + + // PLAYERS MECHANINCS + int playerMakePlay(); // returns & plays a valid move from player + + // FILES + void saveGame(); // saves game into file + bool loadGame(); // loads game from file (if any) + void clearFile() const; // clears file + + struct stats; + void swap(stats *, stats *); + void selectionSort(stats [], int); + void saveScore(bool, string); + void leaderboard() const; +}; + + +#endif // CPVP_H diff --git a/Connect4/main.cpp b/Connect4/main.cpp new file mode 100644 index 0000000..bae3502 --- /dev/null +++ b/Connect4/main.cpp @@ -0,0 +1,440 @@ +#include +#include +#include "cpvm.h" +#include "cpvp.h" +#include "cmvm.h" + +using namespace std; + +void mainMenu(); +void newGame(); +void showLeaderboard(); +void showLeaderboardPvM(); +void showLeaderboardPvP(); +void commands(); +void resumeGame(); +string setName(); + +void newPvM(); +void newPvP(); +void newMvM(); + +void resumePvM(); +void resumePvP(); +void resumeMvM(); + + +int main(){ + mainMenu(); +} + + +void mainMenu(){ + char option; + do{ + system("cls"); + cout << "Welcome to Connect 4" << endl << endl + << "1) New Game" << endl + << "2) Resume Game" << endl + << "3) Leaderboards" << endl + << "4) Commands" << endl + << "0) Quit" << endl << endl + << "Choose an option: "; + cin >> option; + }while(option < '0' || option > '4'); + + switch(option){ + case '1': newGame(); break; + case '2': resumeGame(); break; + case '3': showLeaderboard(); break; + case '4': commands(); break; + case '0': exit(0); + } +} +void newGame(){ + // set game mode + char mode; + do{ + system("cls"); + cout << "Choose your game mode:" << endl << endl + << "1) Player vs Machine" << endl + << "2) Player vs Player" << endl + << "3) Machine vs Machine" << endl + << "0) Exit" << endl << endl + << "Choose an option: "; + + cin >> mode; + if(mode == '0'){ mainMenu(); } + system("cls"); + }while(mode < '0' || mode > '3'); + + switch (mode) { + case '1': newPvM(); break; + case '2': newPvP(); break; + case '3': newMvM(); break; + case '0': mainMenu(); + + } + +} +void showLeaderboard(){ + char mode; + do{ + system("cls"); + cout << "Choose a game mode leaderboard: " << endl << endl + << "1) Player vs Machine" << endl + << "2) Player vs Player" << endl + << "0) Quit" << endl << endl + << "Choose an option: "; + cin >> mode; + if(mode == '0'){ mainMenu(); } + system("cls"); + }while(mode < '0' || mode > '2'); + + switch(mode){ + case '1': showLeaderboardPvM(); break; + case '2': showLeaderboardPvP(); break; + case '0': mainMenu(); + } + +} +void showLeaderboardPvM(){ + CPvM* game = new CPvM (); + system("cls"); + game->leaderboard(); + system("pause"); + delete game; + mainMenu(); +} +void showLeaderboardPvP(){ + CPvP* game = new CPvP (); + system("cls"); + game->leaderboard(); + system("pause"); + delete game; + mainMenu(); +} +void commands(){ + system("cls"); + cout << "Game Commands:" << endl << endl + << "Choose a collumn [1..7] to make your move" << endl + << "type \"0\" to force close the game" << endl + << "type \"-\" to undo your last play" << endl + << "type \"+\" to go forward one play" << endl << endl; + system("pause"); + mainMenu(); +} + +string setName(string n){ + string name; + do{ + getline(cin, name); + if(name == n) cout << "Invalid name" << endl << "Try again: "; + } while (name.size() > 18 || name == n || name == ""); + return name; +} +void newPvM(){ + CPvM* game = new CPvM (); + if(game->loadGame()){ + delete game; + char aux; + do{ + system("cls"); + cout << "Your previous game is still unfinished." << endl + << "If you continue, your progress will be lost." << endl << endl + << "1) Start a new game anyways" << endl + << "2) Resume saved game" << endl + << "0) Back" << endl << endl + << "Choose an option: "; + cin >> aux; + } while (aux <'0' || aux >'2'); + switch (aux){ + case '1': break; + case '2': resumePvM(); break; + case '0': mainMenu(); + } + } else delete game; + + // set name + string name; + system("cls"); + cout << "Your Name: "; + cin.ignore(); + name = setName(" "); + + // set dificulty + char difficulty; + + do{ + system("cls"); + cout << "Hello " << name; + cout << endl; + + cout << "Choose your difficulty:" << endl << endl + << "1) Easy" << endl + << "2) Medium" << endl + << "3) Hard" << endl + << "4) Extreme" << endl + << "0) Exit" << endl << endl + << "Choose an option: "; + + cin >> difficulty; + if(difficulty == '0'){ mainMenu(); } + system("cls"); + }while(difficulty < '0' || difficulty > '4'); + + // set first player + char starter_char; + int starter_int; + do{ + system("cls"); + switch (difficulty) { + case '1': cout << "Difficulty: Easy" << endl; break; + case '2': cout << "Difficulty: Medium" << endl; break; + case '3': cout << "Difficulty: Hard" << endl; break; + case '4': cout << "Difficulty: Extreme" << endl; + } + cout << "Who makes the first play?" << endl << endl + << "1) Human" << endl + << "2) Computer" << endl + << "3) It's whatever" << endl + << "0) Exit" << endl << endl + << "Choose an option: "; + cin >> starter_char; + if(starter_char == '0'){ mainMenu(); } + } while(starter_char < '0' || starter_char > '3'); + + switch (starter_char) { + case '1': starter_int = 1; break; + case '2': starter_int = 2; break; + case '3': srand (time(NULL)); + starter_int = rand() % 2 + 1; + } + + switch (starter_int) { + case 1: starter_char = 'O'; break; + case 2: starter_char = '0'; break; + } + + CPvM *g = new CPvM (name, (int)difficulty-48, starter_char); + g->playGame(); + delete g; + mainMenu(); + +} +void newPvP(){ + CPvP* game = new CPvP (); + if(game->loadGame()){ + delete game; + char aux; + do{ + system("cls"); + cout << "Your previous game is still unfinished." << endl + << "If you continue, your progress will be lost." << endl << endl + << "1) Start a new game anyways" << endl + << "2) Resume saved game" << endl + << "0) Back" << endl << endl + << "Choose an option: "; + cin >> aux; + } while (aux <'0' || aux >'2'); + switch (aux){ + case '1': break; + case '2': resumePvP(); break; + case '0': mainMenu(); + } + } else delete game; + + // set name + system("cls"); + cout << "Player 1 name: "; + cin.ignore(); + string name1 = setName(" "); + + cout << "Player 2 name: "; + string name2 = setName(name1); + + char starter_char; + int starter_int; + do{ + system("cls"); + cout << "Who wants to play first?" << endl << endl + << "1) " << name1 << endl + << "2) " << name2 << endl + << "3) It's whatever" << endl + << "0) Exit" << endl << endl + << "Choose an option: "; + cin >> starter_char; + if(starter_char == '0'){ mainMenu(); } + system("cls"); + } while(starter_char < '0' || starter_char > '3'); + + + switch (starter_char) { + case '1': starter_int = 1; break; + case '2': starter_int = 2; break; + case '3': srand (time(NULL)); + starter_int = rand() % 2 + 1; + } + + switch (starter_int) { + case 1: starter_char = 'O'; break; + case 2: starter_char = '0'; break; + } + cout << starter_char << endl; + CPvP* game_pvm = new CPvP (name1, name2, starter_char); + game_pvm->playGame(); + delete game_pvm; + mainMenu(); + + +} +void newMvM(){ + CMvM* game = new CMvM (); + if(game->loadGame()){ + delete game; + char aux; + do{ + system("cls"); + cout << "Your previous game is still unfinished." << endl + << "If you continue, your progress will be lost." << endl << endl + << "1) Start a new game anyways" << endl + << "2) Resume saved game" << endl + << "0) Back" << endl << endl + << "Choose an option: "; + cin >> aux; + } while (aux <'0' || aux >'2'); + switch (aux){ + case '1': break; + case '2': resumeMvM(); break; + case '0': mainMenu(); + } + } else delete game; + + char dif1, dif2; + + // set dificulty of Machine 1 + do{ + system("cls"); + cout << "Choose Machine's 1 difficulty:" << endl << endl + << "1) Easy" << endl + << "2) Medium" << endl + << "3) Hard" << endl + << "4) Extreme" << endl + << "0) Exit" << endl << endl + << "Choose an option: "; + + cin >> dif1; + if(dif1 == '0'){ mainMenu(); } + system("cls"); + }while(dif1 < '0' || dif1 > '4'); + + // set dificulty of Machine 2 + do{ + system("cls"); + cout << "Choose Machine's 2 difficulty:" << endl << endl + << "1) Easy" << endl + << "2) Medium" << endl + << "3) Hard" << endl + << "4) Extreme" << endl + << "0) Exit" << endl << endl + << "Choose an option: "; + + cin >> dif2; + if(dif2 == '0'){ mainMenu(); } + system("cls"); + }while(dif2 < '0' || dif2 > '4'); + + // set first player + char starter_char; + int starter_int; + do{ + system("cls"); + cout << "Who makes the first play?" << endl << endl + << "1) Machine 1" << endl + << "2) Machine 2" << endl + << "3) It's whatever" << endl + << "0) Exit" << endl << endl + << "Choose an option: "; + cin >> starter_char; + if(starter_char == '0'){ mainMenu(); } + } while(starter_char < '0' || starter_char > '3'); + + switch (starter_char) { + case '1': starter_int = 1; break; + case '2': starter_int = 2; break; + case '3': srand (time(NULL)); + starter_int = rand() % 2 + 1; + } + + switch (starter_int) { + case 1: starter_char = 'O'; break; + case 2: starter_char = '0'; break; + } + + CMvM *g = new CMvM ((int)dif1-48, (int)dif2-48, starter_char); + g->playGame(); + delete g; + mainMenu(); +} + +void resumeGame(){ + char mode; + do{ + system("cls"); + cout << "Choose your game mode to resume:" << endl << endl + << "1) Player vs Machine" << endl + << "2) Player vs Player" << endl + << "3) Machine vs Machine" << endl + << "0) Exit" << endl << endl + << "Choose an option: "; + + cin >> mode; + if(mode == '0'){ mainMenu(); } + system("cls"); + }while(mode < '0' || mode > '3'); + + switch (mode) { + case '1': resumePvM(); break; + case '2': resumePvP(); break; + case '3': resumeMvM(); break; + case '0': mainMenu(); + + } +} +void resumePvM(){ + CPvM* game = new CPvM (); + if(game->loadGame()) + game->playGame(); + else{ + system("cls"); + cout << "No game to resume." << endl << endl; + system("pause"); + mainMenu(); + } + delete game; +} +void resumePvP(){ + CPvP* game = new CPvP (); + if(game->loadGame()) + game->playGame(); + else{ + system("cls"); + cout << "No game to resume." << endl << endl; + system("pause"); + mainMenu(); + } + delete game; + +} +void resumeMvM(){ + CMvM* game = new CMvM (); + if(game->loadGame()) + game->playGame(); + else{ + system("cls"); + cout << "No game to resume." << endl << endl; + system("pause"); + mainMenu(); + } + delete game; +} diff --git a/Projeto P.2.docx b/Projeto P.2.docx new file mode 100644 index 0000000..2ce409b Binary files /dev/null and b/Projeto P.2.docx differ diff --git a/Projeto.docx b/Projeto.docx new file mode 100644 index 0000000..71fe4a1 Binary files /dev/null and b/Projeto.docx differ diff --git a/build-Connect4-Desktop_Qt_5_15_2_MinGW_64_bit-Debug/Makefile b/build-Connect4-Desktop_Qt_5_15_2_MinGW_64_bit-Debug/Makefile new file mode 100644 index 0000000..262ef87 --- /dev/null +++ b/build-Connect4-Desktop_Qt_5_15_2_MinGW_64_bit-Debug/Makefile @@ -0,0 +1,438 @@ +############################################################################# +# Makefile for building: Connect4 +# Generated by qmake (3.1) (Qt 5.15.2) +# Project: ..\Connect4\Connect4.pro +# Template: app +# Command: D:\QtCreator\5.15.2\mingw81_64\bin\qmake.exe -o Makefile ..\Connect4\Connect4.pro -spec win32-g++ "CONFIG+=debug" "CONFIG+=qml_debug" +############################################################################# + +MAKEFILE = Makefile + +EQ = = + +first: debug +install: debug-install +uninstall: debug-uninstall +QMAKE = D:\QtCreator\5.15.2\mingw81_64\bin\qmake.exe +DEL_FILE = del +CHK_DIR_EXISTS= if not exist +MKDIR = mkdir +COPY = copy /y +COPY_FILE = copy /y +COPY_DIR = xcopy /s /q /y /i +INSTALL_FILE = copy /y +INSTALL_PROGRAM = copy /y +INSTALL_DIR = xcopy /s /q /y /i +QINSTALL = D:\QtCreator\5.15.2\mingw81_64\bin\qmake.exe -install qinstall +QINSTALL_PROGRAM = D:\QtCreator\5.15.2\mingw81_64\bin\qmake.exe -install qinstall -exe +DEL_FILE = del +SYMLINK = $(QMAKE) -install ln -f -s +DEL_DIR = rmdir +MOVE = move +IDC = idc +IDL = midl +ZIP = zip -r -9 +DEF_FILE = +RES_FILE = +SED = $(QMAKE) -install sed +MOVE = move +SUBTARGETS = \ + debug \ + release + + +debug: FORCE + $(MAKE) -f $(MAKEFILE).Debug +debug-make_first: FORCE + $(MAKE) -f $(MAKEFILE).Debug +debug-all: FORCE + $(MAKE) -f $(MAKEFILE).Debug all +debug-clean: FORCE + $(MAKE) -f $(MAKEFILE).Debug clean +debug-distclean: FORCE + $(MAKE) -f $(MAKEFILE).Debug distclean +debug-install: FORCE + $(MAKE) -f $(MAKEFILE).Debug install +debug-uninstall: FORCE + $(MAKE) -f $(MAKEFILE).Debug uninstall +release: FORCE + $(MAKE) -f $(MAKEFILE).Release +release-make_first: FORCE + $(MAKE) -f $(MAKEFILE).Release +release-all: FORCE + $(MAKE) -f $(MAKEFILE).Release all +release-clean: FORCE + $(MAKE) -f $(MAKEFILE).Release clean +release-distclean: FORCE + $(MAKE) -f $(MAKEFILE).Release distclean +release-install: FORCE + $(MAKE) -f $(MAKEFILE).Release install +release-uninstall: FORCE + $(MAKE) -f $(MAKEFILE).Release uninstall + +Makefile: ../Connect4/Connect4.pro D:/QtCreator/5.15.2/mingw81_64/mkspecs/win32-g++/qmake.conf D:/QtCreator/5.15.2/mingw81_64/mkspecs/features/spec_pre.prf \ + D:/QtCreator/5.15.2/mingw81_64/mkspecs/qdevice.pri \ + D:/QtCreator/5.15.2/mingw81_64/mkspecs/features/device_config.prf \ + D:/QtCreator/5.15.2/mingw81_64/mkspecs/common/sanitize.conf \ + D:/QtCreator/5.15.2/mingw81_64/mkspecs/common/gcc-base.conf \ + D:/QtCreator/5.15.2/mingw81_64/mkspecs/common/g++-base.conf \ + D:/QtCreator/5.15.2/mingw81_64/mkspecs/common/angle.conf \ + D:/QtCreator/5.15.2/mingw81_64/mkspecs/features/win32/windows_vulkan_sdk.prf \ + D:/QtCreator/5.15.2/mingw81_64/mkspecs/common/windows-vulkan.conf \ + D:/QtCreator/5.15.2/mingw81_64/mkspecs/common/g++-win32.conf \ + D:/QtCreator/5.15.2/mingw81_64/mkspecs/common/windows-desktop.conf \ + D:/QtCreator/5.15.2/mingw81_64/mkspecs/qconfig.pri \ + D:/QtCreator/5.15.2/mingw81_64/mkspecs/modules/qt_lib_3danimation.pri \ + D:/QtCreator/5.15.2/mingw81_64/mkspecs/modules/qt_lib_3danimation_private.pri \ + D:/QtCreator/5.15.2/mingw81_64/mkspecs/modules/qt_lib_3dcore.pri \ + D:/QtCreator/5.15.2/mingw81_64/mkspecs/modules/qt_lib_3dcore_private.pri \ + D:/QtCreator/5.15.2/mingw81_64/mkspecs/modules/qt_lib_3dextras.pri \ + D:/QtCreator/5.15.2/mingw81_64/mkspecs/modules/qt_lib_3dextras_private.pri \ + D:/QtCreator/5.15.2/mingw81_64/mkspecs/modules/qt_lib_3dinput.pri \ + D:/QtCreator/5.15.2/mingw81_64/mkspecs/modules/qt_lib_3dinput_private.pri \ + D:/QtCreator/5.15.2/mingw81_64/mkspecs/modules/qt_lib_3dlogic.pri \ + D:/QtCreator/5.15.2/mingw81_64/mkspecs/modules/qt_lib_3dlogic_private.pri \ + D:/QtCreator/5.15.2/mingw81_64/mkspecs/modules/qt_lib_3dquick.pri \ + D:/QtCreator/5.15.2/mingw81_64/mkspecs/modules/qt_lib_3dquick_private.pri \ + D:/QtCreator/5.15.2/mingw81_64/mkspecs/modules/qt_lib_3dquickanimation.pri \ + D:/QtCreator/5.15.2/mingw81_64/mkspecs/modules/qt_lib_3dquickanimation_private.pri \ + D:/QtCreator/5.15.2/mingw81_64/mkspecs/modules/qt_lib_3dquickextras.pri \ + D:/QtCreator/5.15.2/mingw81_64/mkspecs/modules/qt_lib_3dquickextras_private.pri \ + D:/QtCreator/5.15.2/mingw81_64/mkspecs/modules/qt_lib_3dquickinput.pri \ + D:/QtCreator/5.15.2/mingw81_64/mkspecs/modules/qt_lib_3dquickinput_private.pri \ + D:/QtCreator/5.15.2/mingw81_64/mkspecs/modules/qt_lib_3dquickrender.pri \ + D:/QtCreator/5.15.2/mingw81_64/mkspecs/modules/qt_lib_3dquickrender_private.pri \ + D:/QtCreator/5.15.2/mingw81_64/mkspecs/modules/qt_lib_3dquickscene2d.pri \ + D:/QtCreator/5.15.2/mingw81_64/mkspecs/modules/qt_lib_3dquickscene2d_private.pri \ + D:/QtCreator/5.15.2/mingw81_64/mkspecs/modules/qt_lib_3drender.pri \ + D:/QtCreator/5.15.2/mingw81_64/mkspecs/modules/qt_lib_3drender_private.pri \ + D:/QtCreator/5.15.2/mingw81_64/mkspecs/modules/qt_lib_accessibility_support_private.pri \ + D:/QtCreator/5.15.2/mingw81_64/mkspecs/modules/qt_lib_axbase.pri \ + D:/QtCreator/5.15.2/mingw81_64/mkspecs/modules/qt_lib_axbase_private.pri \ + D:/QtCreator/5.15.2/mingw81_64/mkspecs/modules/qt_lib_axcontainer.pri \ + D:/QtCreator/5.15.2/mingw81_64/mkspecs/modules/qt_lib_axcontainer_private.pri \ + D:/QtCreator/5.15.2/mingw81_64/mkspecs/modules/qt_lib_axserver.pri \ + D:/QtCreator/5.15.2/mingw81_64/mkspecs/modules/qt_lib_axserver_private.pri \ + D:/QtCreator/5.15.2/mingw81_64/mkspecs/modules/qt_lib_bluetooth.pri \ + D:/QtCreator/5.15.2/mingw81_64/mkspecs/modules/qt_lib_bluetooth_private.pri \ + D:/QtCreator/5.15.2/mingw81_64/mkspecs/modules/qt_lib_bootstrap_private.pri \ + D:/QtCreator/5.15.2/mingw81_64/mkspecs/modules/qt_lib_concurrent.pri \ + D:/QtCreator/5.15.2/mingw81_64/mkspecs/modules/qt_lib_concurrent_private.pri \ + D:/QtCreator/5.15.2/mingw81_64/mkspecs/modules/qt_lib_core.pri \ + D:/QtCreator/5.15.2/mingw81_64/mkspecs/modules/qt_lib_core_private.pri \ + D:/QtCreator/5.15.2/mingw81_64/mkspecs/modules/qt_lib_dbus.pri \ + D:/QtCreator/5.15.2/mingw81_64/mkspecs/modules/qt_lib_dbus_private.pri \ + D:/QtCreator/5.15.2/mingw81_64/mkspecs/modules/qt_lib_designer.pri \ + D:/QtCreator/5.15.2/mingw81_64/mkspecs/modules/qt_lib_designer_private.pri \ + D:/QtCreator/5.15.2/mingw81_64/mkspecs/modules/qt_lib_designercomponents_private.pri \ + D:/QtCreator/5.15.2/mingw81_64/mkspecs/modules/qt_lib_devicediscovery_support_private.pri \ + D:/QtCreator/5.15.2/mingw81_64/mkspecs/modules/qt_lib_edid_support_private.pri \ + D:/QtCreator/5.15.2/mingw81_64/mkspecs/modules/qt_lib_egl_support_private.pri \ + D:/QtCreator/5.15.2/mingw81_64/mkspecs/modules/qt_lib_eventdispatcher_support_private.pri \ + D:/QtCreator/5.15.2/mingw81_64/mkspecs/modules/qt_lib_fb_support_private.pri \ + D:/QtCreator/5.15.2/mingw81_64/mkspecs/modules/qt_lib_fontdatabase_support_private.pri \ + D:/QtCreator/5.15.2/mingw81_64/mkspecs/modules/qt_lib_gamepad.pri \ + D:/QtCreator/5.15.2/mingw81_64/mkspecs/modules/qt_lib_gamepad_private.pri \ + D:/QtCreator/5.15.2/mingw81_64/mkspecs/modules/qt_lib_gui.pri \ + D:/QtCreator/5.15.2/mingw81_64/mkspecs/modules/qt_lib_gui_private.pri \ + D:/QtCreator/5.15.2/mingw81_64/mkspecs/modules/qt_lib_help.pri \ + D:/QtCreator/5.15.2/mingw81_64/mkspecs/modules/qt_lib_help_private.pri \ + D:/QtCreator/5.15.2/mingw81_64/mkspecs/modules/qt_lib_location.pri \ + D:/QtCreator/5.15.2/mingw81_64/mkspecs/modules/qt_lib_location_private.pri \ + D:/QtCreator/5.15.2/mingw81_64/mkspecs/modules/qt_lib_multimedia.pri \ + D:/QtCreator/5.15.2/mingw81_64/mkspecs/modules/qt_lib_multimedia_private.pri \ + D:/QtCreator/5.15.2/mingw81_64/mkspecs/modules/qt_lib_multimediawidgets.pri \ + D:/QtCreator/5.15.2/mingw81_64/mkspecs/modules/qt_lib_multimediawidgets_private.pri \ + D:/QtCreator/5.15.2/mingw81_64/mkspecs/modules/qt_lib_network.pri \ + D:/QtCreator/5.15.2/mingw81_64/mkspecs/modules/qt_lib_network_private.pri \ + D:/QtCreator/5.15.2/mingw81_64/mkspecs/modules/qt_lib_nfc.pri \ + D:/QtCreator/5.15.2/mingw81_64/mkspecs/modules/qt_lib_nfc_private.pri \ + D:/QtCreator/5.15.2/mingw81_64/mkspecs/modules/qt_lib_opengl.pri \ + D:/QtCreator/5.15.2/mingw81_64/mkspecs/modules/qt_lib_opengl_private.pri \ + D:/QtCreator/5.15.2/mingw81_64/mkspecs/modules/qt_lib_openglextensions.pri \ + D:/QtCreator/5.15.2/mingw81_64/mkspecs/modules/qt_lib_openglextensions_private.pri \ + D:/QtCreator/5.15.2/mingw81_64/mkspecs/modules/qt_lib_packetprotocol_private.pri \ + D:/QtCreator/5.15.2/mingw81_64/mkspecs/modules/qt_lib_platformcompositor_support_private.pri \ + D:/QtCreator/5.15.2/mingw81_64/mkspecs/modules/qt_lib_positioning.pri \ + D:/QtCreator/5.15.2/mingw81_64/mkspecs/modules/qt_lib_positioning_private.pri \ + D:/QtCreator/5.15.2/mingw81_64/mkspecs/modules/qt_lib_positioningquick.pri \ + D:/QtCreator/5.15.2/mingw81_64/mkspecs/modules/qt_lib_positioningquick_private.pri \ + D:/QtCreator/5.15.2/mingw81_64/mkspecs/modules/qt_lib_printsupport.pri \ + D:/QtCreator/5.15.2/mingw81_64/mkspecs/modules/qt_lib_printsupport_private.pri \ + D:/QtCreator/5.15.2/mingw81_64/mkspecs/modules/qt_lib_qml.pri \ + D:/QtCreator/5.15.2/mingw81_64/mkspecs/modules/qt_lib_qml_private.pri \ + D:/QtCreator/5.15.2/mingw81_64/mkspecs/modules/qt_lib_qmldebug_private.pri \ + D:/QtCreator/5.15.2/mingw81_64/mkspecs/modules/qt_lib_qmldevtools_private.pri \ + D:/QtCreator/5.15.2/mingw81_64/mkspecs/modules/qt_lib_qmlmodels.pri \ + D:/QtCreator/5.15.2/mingw81_64/mkspecs/modules/qt_lib_qmlmodels_private.pri \ + D:/QtCreator/5.15.2/mingw81_64/mkspecs/modules/qt_lib_qmltest.pri \ + D:/QtCreator/5.15.2/mingw81_64/mkspecs/modules/qt_lib_qmltest_private.pri \ + D:/QtCreator/5.15.2/mingw81_64/mkspecs/modules/qt_lib_qmlworkerscript.pri \ + D:/QtCreator/5.15.2/mingw81_64/mkspecs/modules/qt_lib_qmlworkerscript_private.pri \ + D:/QtCreator/5.15.2/mingw81_64/mkspecs/modules/qt_lib_qtmultimediaquicktools_private.pri \ + D:/QtCreator/5.15.2/mingw81_64/mkspecs/modules/qt_lib_quick.pri \ + D:/QtCreator/5.15.2/mingw81_64/mkspecs/modules/qt_lib_quick_private.pri \ + D:/QtCreator/5.15.2/mingw81_64/mkspecs/modules/qt_lib_quickcontrols2.pri \ + D:/QtCreator/5.15.2/mingw81_64/mkspecs/modules/qt_lib_quickcontrols2_private.pri \ + D:/QtCreator/5.15.2/mingw81_64/mkspecs/modules/qt_lib_quickparticles_private.pri \ + D:/QtCreator/5.15.2/mingw81_64/mkspecs/modules/qt_lib_quickshapes_private.pri \ + D:/QtCreator/5.15.2/mingw81_64/mkspecs/modules/qt_lib_quicktemplates2.pri \ + D:/QtCreator/5.15.2/mingw81_64/mkspecs/modules/qt_lib_quicktemplates2_private.pri \ + D:/QtCreator/5.15.2/mingw81_64/mkspecs/modules/qt_lib_quickwidgets.pri \ + D:/QtCreator/5.15.2/mingw81_64/mkspecs/modules/qt_lib_quickwidgets_private.pri \ + D:/QtCreator/5.15.2/mingw81_64/mkspecs/modules/qt_lib_remoteobjects.pri \ + D:/QtCreator/5.15.2/mingw81_64/mkspecs/modules/qt_lib_remoteobjects_private.pri \ + D:/QtCreator/5.15.2/mingw81_64/mkspecs/modules/qt_lib_repparser.pri \ + D:/QtCreator/5.15.2/mingw81_64/mkspecs/modules/qt_lib_repparser_private.pri \ + D:/QtCreator/5.15.2/mingw81_64/mkspecs/modules/qt_lib_scxml.pri \ + D:/QtCreator/5.15.2/mingw81_64/mkspecs/modules/qt_lib_scxml_private.pri \ + D:/QtCreator/5.15.2/mingw81_64/mkspecs/modules/qt_lib_sensors.pri \ + D:/QtCreator/5.15.2/mingw81_64/mkspecs/modules/qt_lib_sensors_private.pri \ + D:/QtCreator/5.15.2/mingw81_64/mkspecs/modules/qt_lib_serialbus.pri \ + D:/QtCreator/5.15.2/mingw81_64/mkspecs/modules/qt_lib_serialbus_private.pri \ + D:/QtCreator/5.15.2/mingw81_64/mkspecs/modules/qt_lib_serialport.pri \ + D:/QtCreator/5.15.2/mingw81_64/mkspecs/modules/qt_lib_serialport_private.pri \ + D:/QtCreator/5.15.2/mingw81_64/mkspecs/modules/qt_lib_sql.pri \ + D:/QtCreator/5.15.2/mingw81_64/mkspecs/modules/qt_lib_sql_private.pri \ + D:/QtCreator/5.15.2/mingw81_64/mkspecs/modules/qt_lib_svg.pri \ + D:/QtCreator/5.15.2/mingw81_64/mkspecs/modules/qt_lib_svg_private.pri \ + D:/QtCreator/5.15.2/mingw81_64/mkspecs/modules/qt_lib_testlib.pri \ + D:/QtCreator/5.15.2/mingw81_64/mkspecs/modules/qt_lib_testlib_private.pri \ + D:/QtCreator/5.15.2/mingw81_64/mkspecs/modules/qt_lib_texttospeech.pri \ + D:/QtCreator/5.15.2/mingw81_64/mkspecs/modules/qt_lib_texttospeech_private.pri \ + D:/QtCreator/5.15.2/mingw81_64/mkspecs/modules/qt_lib_theme_support_private.pri \ + D:/QtCreator/5.15.2/mingw81_64/mkspecs/modules/qt_lib_uiplugin.pri \ + D:/QtCreator/5.15.2/mingw81_64/mkspecs/modules/qt_lib_uitools.pri \ + D:/QtCreator/5.15.2/mingw81_64/mkspecs/modules/qt_lib_uitools_private.pri \ + D:/QtCreator/5.15.2/mingw81_64/mkspecs/modules/qt_lib_vulkan_support_private.pri \ + D:/QtCreator/5.15.2/mingw81_64/mkspecs/modules/qt_lib_webchannel.pri \ + D:/QtCreator/5.15.2/mingw81_64/mkspecs/modules/qt_lib_webchannel_private.pri \ + D:/QtCreator/5.15.2/mingw81_64/mkspecs/modules/qt_lib_websockets.pri \ + D:/QtCreator/5.15.2/mingw81_64/mkspecs/modules/qt_lib_websockets_private.pri \ + D:/QtCreator/5.15.2/mingw81_64/mkspecs/modules/qt_lib_widgets.pri \ + D:/QtCreator/5.15.2/mingw81_64/mkspecs/modules/qt_lib_widgets_private.pri \ + D:/QtCreator/5.15.2/mingw81_64/mkspecs/modules/qt_lib_windowsuiautomation_support_private.pri \ + D:/QtCreator/5.15.2/mingw81_64/mkspecs/modules/qt_lib_winextras.pri \ + D:/QtCreator/5.15.2/mingw81_64/mkspecs/modules/qt_lib_winextras_private.pri \ + D:/QtCreator/5.15.2/mingw81_64/mkspecs/modules/qt_lib_xml.pri \ + D:/QtCreator/5.15.2/mingw81_64/mkspecs/modules/qt_lib_xml_private.pri \ + D:/QtCreator/5.15.2/mingw81_64/mkspecs/modules/qt_lib_xmlpatterns.pri \ + D:/QtCreator/5.15.2/mingw81_64/mkspecs/modules/qt_lib_xmlpatterns_private.pri \ + D:/QtCreator/5.15.2/mingw81_64/mkspecs/modules/qt_lib_zlib_private.pri \ + D:/QtCreator/5.15.2/mingw81_64/mkspecs/features/qt_functions.prf \ + D:/QtCreator/5.15.2/mingw81_64/mkspecs/features/qt_config.prf \ + D:/QtCreator/5.15.2/mingw81_64/mkspecs/win32-g++/qmake.conf \ + D:/QtCreator/5.15.2/mingw81_64/mkspecs/features/spec_post.prf \ + D:/QtCreator/5.15.2/mingw81_64/mkspecs/features/exclusive_builds.prf \ + D:/QtCreator/5.15.2/mingw81_64/mkspecs/features/toolchain.prf \ + D:/QtCreator/5.15.2/mingw81_64/mkspecs/features/default_pre.prf \ + D:/QtCreator/5.15.2/mingw81_64/mkspecs/features/win32/default_pre.prf \ + D:/QtCreator/5.15.2/mingw81_64/mkspecs/features/resolve_config.prf \ + D:/QtCreator/5.15.2/mingw81_64/mkspecs/features/exclusive_builds_post.prf \ + D:/QtCreator/5.15.2/mingw81_64/mkspecs/features/default_post.prf \ + D:/QtCreator/5.15.2/mingw81_64/mkspecs/features/win32/console.prf \ + D:/QtCreator/5.15.2/mingw81_64/mkspecs/features/qml_debug.prf \ + D:/QtCreator/5.15.2/mingw81_64/mkspecs/features/precompile_header.prf \ + D:/QtCreator/5.15.2/mingw81_64/mkspecs/features/warn_on.prf \ + D:/QtCreator/5.15.2/mingw81_64/mkspecs/features/qmake_use.prf \ + D:/QtCreator/5.15.2/mingw81_64/mkspecs/features/file_copies.prf \ + D:/QtCreator/5.15.2/mingw81_64/mkspecs/features/testcase_targets.prf \ + D:/QtCreator/5.15.2/mingw81_64/mkspecs/features/exceptions.prf \ + D:/QtCreator/5.15.2/mingw81_64/mkspecs/features/yacc.prf \ + D:/QtCreator/5.15.2/mingw81_64/mkspecs/features/lex.prf \ + ../Connect4/Connect4.pro \ + .qmake.stash \ + D:/QtCreator/5.15.2/mingw81_64/mkspecs/features/build_pass.prf + $(QMAKE) -o Makefile ..\Connect4\Connect4.pro -spec win32-g++ "CONFIG+=debug" "CONFIG+=qml_debug" +D:/QtCreator/5.15.2/mingw81_64/mkspecs/features/spec_pre.prf: +D:/QtCreator/5.15.2/mingw81_64/mkspecs/qdevice.pri: +D:/QtCreator/5.15.2/mingw81_64/mkspecs/features/device_config.prf: +D:/QtCreator/5.15.2/mingw81_64/mkspecs/common/sanitize.conf: +D:/QtCreator/5.15.2/mingw81_64/mkspecs/common/gcc-base.conf: +D:/QtCreator/5.15.2/mingw81_64/mkspecs/common/g++-base.conf: +D:/QtCreator/5.15.2/mingw81_64/mkspecs/common/angle.conf: +D:/QtCreator/5.15.2/mingw81_64/mkspecs/features/win32/windows_vulkan_sdk.prf: +D:/QtCreator/5.15.2/mingw81_64/mkspecs/common/windows-vulkan.conf: +D:/QtCreator/5.15.2/mingw81_64/mkspecs/common/g++-win32.conf: +D:/QtCreator/5.15.2/mingw81_64/mkspecs/common/windows-desktop.conf: +D:/QtCreator/5.15.2/mingw81_64/mkspecs/qconfig.pri: +D:/QtCreator/5.15.2/mingw81_64/mkspecs/modules/qt_lib_3danimation.pri: +D:/QtCreator/5.15.2/mingw81_64/mkspecs/modules/qt_lib_3danimation_private.pri: +D:/QtCreator/5.15.2/mingw81_64/mkspecs/modules/qt_lib_3dcore.pri: +D:/QtCreator/5.15.2/mingw81_64/mkspecs/modules/qt_lib_3dcore_private.pri: +D:/QtCreator/5.15.2/mingw81_64/mkspecs/modules/qt_lib_3dextras.pri: +D:/QtCreator/5.15.2/mingw81_64/mkspecs/modules/qt_lib_3dextras_private.pri: +D:/QtCreator/5.15.2/mingw81_64/mkspecs/modules/qt_lib_3dinput.pri: +D:/QtCreator/5.15.2/mingw81_64/mkspecs/modules/qt_lib_3dinput_private.pri: +D:/QtCreator/5.15.2/mingw81_64/mkspecs/modules/qt_lib_3dlogic.pri: +D:/QtCreator/5.15.2/mingw81_64/mkspecs/modules/qt_lib_3dlogic_private.pri: +D:/QtCreator/5.15.2/mingw81_64/mkspecs/modules/qt_lib_3dquick.pri: +D:/QtCreator/5.15.2/mingw81_64/mkspecs/modules/qt_lib_3dquick_private.pri: +D:/QtCreator/5.15.2/mingw81_64/mkspecs/modules/qt_lib_3dquickanimation.pri: +D:/QtCreator/5.15.2/mingw81_64/mkspecs/modules/qt_lib_3dquickanimation_private.pri: +D:/QtCreator/5.15.2/mingw81_64/mkspecs/modules/qt_lib_3dquickextras.pri: +D:/QtCreator/5.15.2/mingw81_64/mkspecs/modules/qt_lib_3dquickextras_private.pri: +D:/QtCreator/5.15.2/mingw81_64/mkspecs/modules/qt_lib_3dquickinput.pri: +D:/QtCreator/5.15.2/mingw81_64/mkspecs/modules/qt_lib_3dquickinput_private.pri: +D:/QtCreator/5.15.2/mingw81_64/mkspecs/modules/qt_lib_3dquickrender.pri: +D:/QtCreator/5.15.2/mingw81_64/mkspecs/modules/qt_lib_3dquickrender_private.pri: +D:/QtCreator/5.15.2/mingw81_64/mkspecs/modules/qt_lib_3dquickscene2d.pri: +D:/QtCreator/5.15.2/mingw81_64/mkspecs/modules/qt_lib_3dquickscene2d_private.pri: +D:/QtCreator/5.15.2/mingw81_64/mkspecs/modules/qt_lib_3drender.pri: +D:/QtCreator/5.15.2/mingw81_64/mkspecs/modules/qt_lib_3drender_private.pri: +D:/QtCreator/5.15.2/mingw81_64/mkspecs/modules/qt_lib_accessibility_support_private.pri: +D:/QtCreator/5.15.2/mingw81_64/mkspecs/modules/qt_lib_axbase.pri: +D:/QtCreator/5.15.2/mingw81_64/mkspecs/modules/qt_lib_axbase_private.pri: +D:/QtCreator/5.15.2/mingw81_64/mkspecs/modules/qt_lib_axcontainer.pri: +D:/QtCreator/5.15.2/mingw81_64/mkspecs/modules/qt_lib_axcontainer_private.pri: +D:/QtCreator/5.15.2/mingw81_64/mkspecs/modules/qt_lib_axserver.pri: +D:/QtCreator/5.15.2/mingw81_64/mkspecs/modules/qt_lib_axserver_private.pri: +D:/QtCreator/5.15.2/mingw81_64/mkspecs/modules/qt_lib_bluetooth.pri: +D:/QtCreator/5.15.2/mingw81_64/mkspecs/modules/qt_lib_bluetooth_private.pri: +D:/QtCreator/5.15.2/mingw81_64/mkspecs/modules/qt_lib_bootstrap_private.pri: +D:/QtCreator/5.15.2/mingw81_64/mkspecs/modules/qt_lib_concurrent.pri: +D:/QtCreator/5.15.2/mingw81_64/mkspecs/modules/qt_lib_concurrent_private.pri: +D:/QtCreator/5.15.2/mingw81_64/mkspecs/modules/qt_lib_core.pri: +D:/QtCreator/5.15.2/mingw81_64/mkspecs/modules/qt_lib_core_private.pri: +D:/QtCreator/5.15.2/mingw81_64/mkspecs/modules/qt_lib_dbus.pri: +D:/QtCreator/5.15.2/mingw81_64/mkspecs/modules/qt_lib_dbus_private.pri: +D:/QtCreator/5.15.2/mingw81_64/mkspecs/modules/qt_lib_designer.pri: +D:/QtCreator/5.15.2/mingw81_64/mkspecs/modules/qt_lib_designer_private.pri: +D:/QtCreator/5.15.2/mingw81_64/mkspecs/modules/qt_lib_designercomponents_private.pri: +D:/QtCreator/5.15.2/mingw81_64/mkspecs/modules/qt_lib_devicediscovery_support_private.pri: +D:/QtCreator/5.15.2/mingw81_64/mkspecs/modules/qt_lib_edid_support_private.pri: +D:/QtCreator/5.15.2/mingw81_64/mkspecs/modules/qt_lib_egl_support_private.pri: +D:/QtCreator/5.15.2/mingw81_64/mkspecs/modules/qt_lib_eventdispatcher_support_private.pri: +D:/QtCreator/5.15.2/mingw81_64/mkspecs/modules/qt_lib_fb_support_private.pri: +D:/QtCreator/5.15.2/mingw81_64/mkspecs/modules/qt_lib_fontdatabase_support_private.pri: +D:/QtCreator/5.15.2/mingw81_64/mkspecs/modules/qt_lib_gamepad.pri: +D:/QtCreator/5.15.2/mingw81_64/mkspecs/modules/qt_lib_gamepad_private.pri: +D:/QtCreator/5.15.2/mingw81_64/mkspecs/modules/qt_lib_gui.pri: +D:/QtCreator/5.15.2/mingw81_64/mkspecs/modules/qt_lib_gui_private.pri: +D:/QtCreator/5.15.2/mingw81_64/mkspecs/modules/qt_lib_help.pri: +D:/QtCreator/5.15.2/mingw81_64/mkspecs/modules/qt_lib_help_private.pri: +D:/QtCreator/5.15.2/mingw81_64/mkspecs/modules/qt_lib_location.pri: +D:/QtCreator/5.15.2/mingw81_64/mkspecs/modules/qt_lib_location_private.pri: +D:/QtCreator/5.15.2/mingw81_64/mkspecs/modules/qt_lib_multimedia.pri: +D:/QtCreator/5.15.2/mingw81_64/mkspecs/modules/qt_lib_multimedia_private.pri: +D:/QtCreator/5.15.2/mingw81_64/mkspecs/modules/qt_lib_multimediawidgets.pri: +D:/QtCreator/5.15.2/mingw81_64/mkspecs/modules/qt_lib_multimediawidgets_private.pri: +D:/QtCreator/5.15.2/mingw81_64/mkspecs/modules/qt_lib_network.pri: +D:/QtCreator/5.15.2/mingw81_64/mkspecs/modules/qt_lib_network_private.pri: +D:/QtCreator/5.15.2/mingw81_64/mkspecs/modules/qt_lib_nfc.pri: +D:/QtCreator/5.15.2/mingw81_64/mkspecs/modules/qt_lib_nfc_private.pri: +D:/QtCreator/5.15.2/mingw81_64/mkspecs/modules/qt_lib_opengl.pri: +D:/QtCreator/5.15.2/mingw81_64/mkspecs/modules/qt_lib_opengl_private.pri: +D:/QtCreator/5.15.2/mingw81_64/mkspecs/modules/qt_lib_openglextensions.pri: +D:/QtCreator/5.15.2/mingw81_64/mkspecs/modules/qt_lib_openglextensions_private.pri: +D:/QtCreator/5.15.2/mingw81_64/mkspecs/modules/qt_lib_packetprotocol_private.pri: +D:/QtCreator/5.15.2/mingw81_64/mkspecs/modules/qt_lib_platformcompositor_support_private.pri: +D:/QtCreator/5.15.2/mingw81_64/mkspecs/modules/qt_lib_positioning.pri: +D:/QtCreator/5.15.2/mingw81_64/mkspecs/modules/qt_lib_positioning_private.pri: +D:/QtCreator/5.15.2/mingw81_64/mkspecs/modules/qt_lib_positioningquick.pri: +D:/QtCreator/5.15.2/mingw81_64/mkspecs/modules/qt_lib_positioningquick_private.pri: +D:/QtCreator/5.15.2/mingw81_64/mkspecs/modules/qt_lib_printsupport.pri: +D:/QtCreator/5.15.2/mingw81_64/mkspecs/modules/qt_lib_printsupport_private.pri: +D:/QtCreator/5.15.2/mingw81_64/mkspecs/modules/qt_lib_qml.pri: +D:/QtCreator/5.15.2/mingw81_64/mkspecs/modules/qt_lib_qml_private.pri: +D:/QtCreator/5.15.2/mingw81_64/mkspecs/modules/qt_lib_qmldebug_private.pri: +D:/QtCreator/5.15.2/mingw81_64/mkspecs/modules/qt_lib_qmldevtools_private.pri: +D:/QtCreator/5.15.2/mingw81_64/mkspecs/modules/qt_lib_qmlmodels.pri: +D:/QtCreator/5.15.2/mingw81_64/mkspecs/modules/qt_lib_qmlmodels_private.pri: +D:/QtCreator/5.15.2/mingw81_64/mkspecs/modules/qt_lib_qmltest.pri: +D:/QtCreator/5.15.2/mingw81_64/mkspecs/modules/qt_lib_qmltest_private.pri: +D:/QtCreator/5.15.2/mingw81_64/mkspecs/modules/qt_lib_qmlworkerscript.pri: +D:/QtCreator/5.15.2/mingw81_64/mkspecs/modules/qt_lib_qmlworkerscript_private.pri: +D:/QtCreator/5.15.2/mingw81_64/mkspecs/modules/qt_lib_qtmultimediaquicktools_private.pri: +D:/QtCreator/5.15.2/mingw81_64/mkspecs/modules/qt_lib_quick.pri: +D:/QtCreator/5.15.2/mingw81_64/mkspecs/modules/qt_lib_quick_private.pri: +D:/QtCreator/5.15.2/mingw81_64/mkspecs/modules/qt_lib_quickcontrols2.pri: +D:/QtCreator/5.15.2/mingw81_64/mkspecs/modules/qt_lib_quickcontrols2_private.pri: +D:/QtCreator/5.15.2/mingw81_64/mkspecs/modules/qt_lib_quickparticles_private.pri: +D:/QtCreator/5.15.2/mingw81_64/mkspecs/modules/qt_lib_quickshapes_private.pri: +D:/QtCreator/5.15.2/mingw81_64/mkspecs/modules/qt_lib_quicktemplates2.pri: +D:/QtCreator/5.15.2/mingw81_64/mkspecs/modules/qt_lib_quicktemplates2_private.pri: +D:/QtCreator/5.15.2/mingw81_64/mkspecs/modules/qt_lib_quickwidgets.pri: +D:/QtCreator/5.15.2/mingw81_64/mkspecs/modules/qt_lib_quickwidgets_private.pri: +D:/QtCreator/5.15.2/mingw81_64/mkspecs/modules/qt_lib_remoteobjects.pri: +D:/QtCreator/5.15.2/mingw81_64/mkspecs/modules/qt_lib_remoteobjects_private.pri: +D:/QtCreator/5.15.2/mingw81_64/mkspecs/modules/qt_lib_repparser.pri: +D:/QtCreator/5.15.2/mingw81_64/mkspecs/modules/qt_lib_repparser_private.pri: +D:/QtCreator/5.15.2/mingw81_64/mkspecs/modules/qt_lib_scxml.pri: +D:/QtCreator/5.15.2/mingw81_64/mkspecs/modules/qt_lib_scxml_private.pri: +D:/QtCreator/5.15.2/mingw81_64/mkspecs/modules/qt_lib_sensors.pri: +D:/QtCreator/5.15.2/mingw81_64/mkspecs/modules/qt_lib_sensors_private.pri: +D:/QtCreator/5.15.2/mingw81_64/mkspecs/modules/qt_lib_serialbus.pri: +D:/QtCreator/5.15.2/mingw81_64/mkspecs/modules/qt_lib_serialbus_private.pri: +D:/QtCreator/5.15.2/mingw81_64/mkspecs/modules/qt_lib_serialport.pri: +D:/QtCreator/5.15.2/mingw81_64/mkspecs/modules/qt_lib_serialport_private.pri: +D:/QtCreator/5.15.2/mingw81_64/mkspecs/modules/qt_lib_sql.pri: +D:/QtCreator/5.15.2/mingw81_64/mkspecs/modules/qt_lib_sql_private.pri: +D:/QtCreator/5.15.2/mingw81_64/mkspecs/modules/qt_lib_svg.pri: +D:/QtCreator/5.15.2/mingw81_64/mkspecs/modules/qt_lib_svg_private.pri: +D:/QtCreator/5.15.2/mingw81_64/mkspecs/modules/qt_lib_testlib.pri: +D:/QtCreator/5.15.2/mingw81_64/mkspecs/modules/qt_lib_testlib_private.pri: +D:/QtCreator/5.15.2/mingw81_64/mkspecs/modules/qt_lib_texttospeech.pri: +D:/QtCreator/5.15.2/mingw81_64/mkspecs/modules/qt_lib_texttospeech_private.pri: +D:/QtCreator/5.15.2/mingw81_64/mkspecs/modules/qt_lib_theme_support_private.pri: +D:/QtCreator/5.15.2/mingw81_64/mkspecs/modules/qt_lib_uiplugin.pri: +D:/QtCreator/5.15.2/mingw81_64/mkspecs/modules/qt_lib_uitools.pri: +D:/QtCreator/5.15.2/mingw81_64/mkspecs/modules/qt_lib_uitools_private.pri: +D:/QtCreator/5.15.2/mingw81_64/mkspecs/modules/qt_lib_vulkan_support_private.pri: +D:/QtCreator/5.15.2/mingw81_64/mkspecs/modules/qt_lib_webchannel.pri: +D:/QtCreator/5.15.2/mingw81_64/mkspecs/modules/qt_lib_webchannel_private.pri: +D:/QtCreator/5.15.2/mingw81_64/mkspecs/modules/qt_lib_websockets.pri: +D:/QtCreator/5.15.2/mingw81_64/mkspecs/modules/qt_lib_websockets_private.pri: +D:/QtCreator/5.15.2/mingw81_64/mkspecs/modules/qt_lib_widgets.pri: +D:/QtCreator/5.15.2/mingw81_64/mkspecs/modules/qt_lib_widgets_private.pri: +D:/QtCreator/5.15.2/mingw81_64/mkspecs/modules/qt_lib_windowsuiautomation_support_private.pri: +D:/QtCreator/5.15.2/mingw81_64/mkspecs/modules/qt_lib_winextras.pri: +D:/QtCreator/5.15.2/mingw81_64/mkspecs/modules/qt_lib_winextras_private.pri: +D:/QtCreator/5.15.2/mingw81_64/mkspecs/modules/qt_lib_xml.pri: +D:/QtCreator/5.15.2/mingw81_64/mkspecs/modules/qt_lib_xml_private.pri: +D:/QtCreator/5.15.2/mingw81_64/mkspecs/modules/qt_lib_xmlpatterns.pri: +D:/QtCreator/5.15.2/mingw81_64/mkspecs/modules/qt_lib_xmlpatterns_private.pri: +D:/QtCreator/5.15.2/mingw81_64/mkspecs/modules/qt_lib_zlib_private.pri: +D:/QtCreator/5.15.2/mingw81_64/mkspecs/features/qt_functions.prf: +D:/QtCreator/5.15.2/mingw81_64/mkspecs/features/qt_config.prf: +D:/QtCreator/5.15.2/mingw81_64/mkspecs/win32-g++/qmake.conf: +D:/QtCreator/5.15.2/mingw81_64/mkspecs/features/spec_post.prf: +D:/QtCreator/5.15.2/mingw81_64/mkspecs/features/exclusive_builds.prf: +D:/QtCreator/5.15.2/mingw81_64/mkspecs/features/toolchain.prf: +D:/QtCreator/5.15.2/mingw81_64/mkspecs/features/default_pre.prf: +D:/QtCreator/5.15.2/mingw81_64/mkspecs/features/win32/default_pre.prf: +D:/QtCreator/5.15.2/mingw81_64/mkspecs/features/resolve_config.prf: +D:/QtCreator/5.15.2/mingw81_64/mkspecs/features/exclusive_builds_post.prf: +D:/QtCreator/5.15.2/mingw81_64/mkspecs/features/default_post.prf: +D:/QtCreator/5.15.2/mingw81_64/mkspecs/features/win32/console.prf: +D:/QtCreator/5.15.2/mingw81_64/mkspecs/features/qml_debug.prf: +D:/QtCreator/5.15.2/mingw81_64/mkspecs/features/precompile_header.prf: +D:/QtCreator/5.15.2/mingw81_64/mkspecs/features/warn_on.prf: +D:/QtCreator/5.15.2/mingw81_64/mkspecs/features/qmake_use.prf: +D:/QtCreator/5.15.2/mingw81_64/mkspecs/features/file_copies.prf: +D:/QtCreator/5.15.2/mingw81_64/mkspecs/features/testcase_targets.prf: +D:/QtCreator/5.15.2/mingw81_64/mkspecs/features/exceptions.prf: +D:/QtCreator/5.15.2/mingw81_64/mkspecs/features/yacc.prf: +D:/QtCreator/5.15.2/mingw81_64/mkspecs/features/lex.prf: +../Connect4/Connect4.pro: +.qmake.stash: +D:/QtCreator/5.15.2/mingw81_64/mkspecs/features/build_pass.prf: +qmake: FORCE + @$(QMAKE) -o Makefile ..\Connect4\Connect4.pro -spec win32-g++ "CONFIG+=debug" "CONFIG+=qml_debug" + +qmake_all: FORCE + +make_first: debug-make_first release-make_first FORCE +all: debug-all release-all FORCE +clean: debug-clean release-clean FORCE +distclean: debug-distclean release-distclean FORCE + -$(DEL_FILE) Makefile + -$(DEL_FILE) .qmake.stash + +check: first + +benchmark: first +FORCE: + +$(MAKEFILE).Debug: Makefile +$(MAKEFILE).Release: Makefile diff --git a/build-Connect4-Desktop_Qt_5_15_2_MinGW_64_bit-Debug/leaderboard_pvp.txt b/build-Connect4-Desktop_Qt_5_15_2_MinGW_64_bit-Debug/leaderboard_pvp.txt new file mode 100644 index 0000000..a551567 --- /dev/null +++ b/build-Connect4-Desktop_Qt_5_15_2_MinGW_64_bit-Debug/leaderboard_pvp.txt @@ -0,0 +1,7 @@ +2 +RykenWay +1 +0 +ZeptusG +0 +1 \ No newline at end of file diff --git a/projeto_eda.pdf b/projeto_eda.pdf new file mode 100644 index 0000000..51a4b78 Binary files /dev/null and b/projeto_eda.pdf differ