Remove main.cpp.
This commit is contained in:
parent
6e0758085b
commit
545b650013
1 changed files with 0 additions and 893 deletions
893
main.cpp
893
main.cpp
|
@ -1,893 +0,0 @@
|
|||
#include <iostream>
|
||||
#include <vector>
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
|
||||
|
||||
|
||||
using namespace std;
|
||||
|
||||
// class piece
|
||||
// {
|
||||
// char color; //w for white, b for white, e for empty
|
||||
// int xpos;
|
||||
// int ypos;
|
||||
|
||||
// public:
|
||||
|
||||
// piece(int x, int y)
|
||||
// {
|
||||
// xpos = x;
|
||||
// ypos = y;
|
||||
// }
|
||||
|
||||
// void setColor(char kolor)
|
||||
// {
|
||||
// color = kolor;
|
||||
// }
|
||||
|
||||
// char getColor()
|
||||
// {
|
||||
// return color;
|
||||
// }
|
||||
// };
|
||||
|
||||
string myToUpper(string input)
|
||||
{
|
||||
string output;
|
||||
|
||||
for (int i = 0 ; i < input.size(); ++i)
|
||||
{
|
||||
int numeric;
|
||||
|
||||
if ((input[i] - 0 >= 97) && (input[i] - 0 <= 122))
|
||||
{
|
||||
numeric = input[i] - 32;
|
||||
output.push_back((char)numeric);// = 'Q';//(char) numeric;
|
||||
}
|
||||
else output.push_back(input[i]);
|
||||
}
|
||||
|
||||
for (int i = 0; i < output.size(); ++i)
|
||||
{
|
||||
cout<<output[i]<<endl;
|
||||
}
|
||||
|
||||
return output;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
struct moves
|
||||
{
|
||||
int row;
|
||||
char column;
|
||||
string moveType;
|
||||
|
||||
moves(int linea, int columna, string m)
|
||||
{
|
||||
row = linea;
|
||||
column = columna;
|
||||
moveType = m;
|
||||
}
|
||||
|
||||
void display()
|
||||
{
|
||||
cout<<column<<row<<" "<<moveType<<endl;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
class Board
|
||||
{
|
||||
char boardArray [8][8];
|
||||
char turn = 'O';
|
||||
|
||||
public:
|
||||
|
||||
Board()
|
||||
{
|
||||
for (int i = 0; i < 2; ++i)
|
||||
{
|
||||
for (int j = 0; j < 8; ++j)
|
||||
{
|
||||
boardArray[i][j] = 'X';
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
for (int i = 2; i < 6; ++i)
|
||||
{
|
||||
for (int j = 0; j < 8; ++j)
|
||||
{
|
||||
boardArray[i][j] = '_';
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
for (int i = 6; i <= 7; ++i)
|
||||
{
|
||||
for (int j = 0; j < 8; ++j)
|
||||
{
|
||||
boardArray[i][j] = 'O';
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
char elementAt(int r, int k)
|
||||
{
|
||||
return boardArray[r][k];
|
||||
}
|
||||
|
||||
void modifyAt(int r, int k, char input)
|
||||
{
|
||||
boardArray[r][k] = input;
|
||||
}
|
||||
|
||||
moves parse(string input)
|
||||
{
|
||||
|
||||
input = myToUpper(input);
|
||||
|
||||
cout<<input<<endl;
|
||||
|
||||
int temp1;
|
||||
char temp2;
|
||||
string temp3;
|
||||
|
||||
temp2 = input[0];
|
||||
temp1 = input[1] - '0';
|
||||
|
||||
if (input[3] == 'L')
|
||||
{
|
||||
temp3 = "LEFT";
|
||||
}
|
||||
|
||||
else if (input[3] == 'R')
|
||||
{
|
||||
temp3 = "RIGHT";
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
temp3 = "FWD";
|
||||
}
|
||||
|
||||
moves output(temp1,temp2,temp3);
|
||||
|
||||
return output;
|
||||
|
||||
}
|
||||
|
||||
char getTurn()
|
||||
{
|
||||
return turn;
|
||||
}
|
||||
|
||||
bool isGameOver()
|
||||
{
|
||||
for (int i = 0; i < 8; ++i)
|
||||
{
|
||||
|
||||
if (boardArray[0][i] == 'O')
|
||||
{
|
||||
cout<<"\n\n\nplayer O wins!\n\n\n"<<endl;
|
||||
return true;
|
||||
}
|
||||
|
||||
if (boardArray[7][i] == 'X')
|
||||
{
|
||||
cout<<"\n\n\nplayer X wins!\n\n\n"<<endl;
|
||||
return true;
|
||||
}
|
||||
|
||||
// else return false; this line was making this function return false no matter what, apparently...
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void changeTurns()
|
||||
{
|
||||
if (turn == 'O') turn = 'X';
|
||||
else turn = 'O';
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
void displayBoard()
|
||||
{
|
||||
cout<<"\n\n";
|
||||
cout<<" A B C D E F G H"<<endl;
|
||||
for (int i = 0; i < 8; ++i)
|
||||
{
|
||||
int mango = 8 - i;
|
||||
cout<<mango<<" ";
|
||||
for (int j = 0; j < 8; ++j)
|
||||
{
|
||||
cout<<boardArray[i][j]<<" ";
|
||||
}
|
||||
cout<<endl;
|
||||
}
|
||||
cout<<'\n'<<endl;
|
||||
cout<<"turn : "<<turn;
|
||||
}
|
||||
|
||||
|
||||
int charToIntColumn(char input) //converts column number to int
|
||||
{
|
||||
int kolumn;
|
||||
|
||||
switch (input)
|
||||
{
|
||||
case 'A': kolumn = 0; break;
|
||||
case 'B': kolumn = 1; break;
|
||||
case 'C': kolumn = 2; break;
|
||||
case 'D': kolumn = 3; break;
|
||||
case 'E': kolumn = 4; break;
|
||||
case 'F': kolumn = 5; break;
|
||||
case 'G': kolumn = 6; break;
|
||||
case 'H': kolumn = 7; break;
|
||||
}
|
||||
|
||||
return kolumn;
|
||||
}
|
||||
|
||||
|
||||
char intToCharColumn(int input) //converts column number to int
|
||||
{
|
||||
char kolumn;
|
||||
|
||||
switch (input)
|
||||
{
|
||||
case 1: kolumn = 'A'; break;
|
||||
case 2: kolumn = 'B'; break;
|
||||
case 3: kolumn = 'C'; break;
|
||||
case 4: kolumn = 'D'; break;
|
||||
case 5: kolumn = 'E'; break;
|
||||
case 6: kolumn = 'F'; break;
|
||||
case 7: kolumn = 'G'; break;
|
||||
case 8: kolumn = 'H'; break;
|
||||
}
|
||||
|
||||
return kolumn;
|
||||
}
|
||||
|
||||
|
||||
|
||||
void move(string inputMove)
|
||||
{
|
||||
|
||||
moves jugada = parse(inputMove);
|
||||
|
||||
int row = 8 - (jugada.row);
|
||||
int kolumn = charToIntColumn(jugada.column);
|
||||
int temp = boardArray[row][kolumn];
|
||||
int reflector = 1;
|
||||
|
||||
if (row > 8 || row < 0 || kolumn > 8 || kolumn < 0)
|
||||
{
|
||||
cout<<"ERROR: index out of bound!"<<endl;
|
||||
}
|
||||
|
||||
else if (temp != turn)
|
||||
{
|
||||
cout<<"you can't move that piece at this turn!"<<endl;
|
||||
}
|
||||
|
||||
else if (temp == '_')
|
||||
{
|
||||
cout<<"there's no piece in that spot!"<<endl;
|
||||
}
|
||||
|
||||
else if (temp == 'X' || temp == 'O')
|
||||
{
|
||||
|
||||
if (temp == 'O')
|
||||
{
|
||||
reflector *= -1;
|
||||
}
|
||||
|
||||
|
||||
if (jugada.moveType == "FWD")
|
||||
{
|
||||
|
||||
if(boardArray[row+reflector][kolumn] != '_')
|
||||
{
|
||||
cout<<"you can't move that piece forward"<<endl;
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
boardArray[row][kolumn] = '_';
|
||||
boardArray[row+reflector][kolumn] = temp;
|
||||
|
||||
changeTurns();
|
||||
displayBoard();
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
else if (jugada.moveType == "LEFT")
|
||||
{
|
||||
if (kolumn == 0)
|
||||
{
|
||||
cout<<"Destination Spot out of range!"<<endl;
|
||||
}
|
||||
|
||||
else if (boardArray[row+reflector][kolumn-1] == temp)
|
||||
{
|
||||
cout<<"you hate your own team or something? you can't do that!"<<endl;
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
boardArray[row][kolumn] = '_';
|
||||
boardArray[row+reflector][kolumn-1] = temp;
|
||||
|
||||
changeTurns();
|
||||
displayBoard();
|
||||
}
|
||||
}
|
||||
|
||||
else if (jugada.moveType == "RIGHT")
|
||||
{
|
||||
if (kolumn == 7)
|
||||
{
|
||||
cout<<"Destination Spot out of range!"<<endl;
|
||||
}
|
||||
|
||||
else if (boardArray[row+reflector][kolumn+1] == temp)
|
||||
{
|
||||
cout<<"you hate your own team or something? you can't do that!"<<endl;
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
boardArray[row][kolumn] = '_';
|
||||
boardArray[row+reflector][kolumn+1] = temp;
|
||||
|
||||
changeTurns();
|
||||
displayBoard();
|
||||
}
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
cout<<"Unrecognized movetype!"<<endl;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
cout<<"Invalid piece!"<<endl;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
void move(moves jugada)
|
||||
{
|
||||
|
||||
int row = 8 - (jugada.row);
|
||||
int kolumn = charToIntColumn(jugada.column);
|
||||
|
||||
if (row > 8 || row < 0 || kolumn > 8 || kolumn < 0)
|
||||
{
|
||||
cout<<"ERROR: index out of bound!"<<endl;
|
||||
}
|
||||
|
||||
int temp = boardArray[row][kolumn];
|
||||
if (temp != turn)
|
||||
{
|
||||
cout<<"you can't move that piece at this turn!"<<endl;
|
||||
}
|
||||
|
||||
else if (temp == '_')
|
||||
{
|
||||
cout<<"there's no piece in that spot!"<<endl;
|
||||
}
|
||||
|
||||
int reflector = 1;
|
||||
|
||||
if (temp == 'X' || temp == 'O')
|
||||
{
|
||||
|
||||
if (temp == 'O')
|
||||
{
|
||||
reflector *= -1;
|
||||
}
|
||||
|
||||
|
||||
if (jugada.moveType == "FWD")
|
||||
{
|
||||
|
||||
if(boardArray[row+reflector][kolumn] != '_')
|
||||
{
|
||||
cout<<"you can't move that piece forward"<<endl;
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
boardArray[row][kolumn] = '_';
|
||||
boardArray[row+reflector][kolumn] = temp;
|
||||
|
||||
changeTurns();
|
||||
displayBoard();
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
else if (jugada.moveType == "LEFT")
|
||||
{
|
||||
if (kolumn == 0)
|
||||
{
|
||||
cout<<"Destination Spot out of range!"<<endl;
|
||||
}
|
||||
|
||||
else if (boardArray[row+reflector][kolumn-1] == temp)
|
||||
{
|
||||
cout<<"you hate your own team or something? you can't do that!"<<endl;
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
boardArray[row][kolumn] = '_';
|
||||
boardArray[row+reflector][kolumn-1] = temp;
|
||||
|
||||
changeTurns();
|
||||
displayBoard();
|
||||
}
|
||||
}
|
||||
|
||||
else if (jugada.moveType == "RIGHT")
|
||||
{
|
||||
if (kolumn == 7)
|
||||
{
|
||||
cout<<"Destination Spot out of range!"<<endl;
|
||||
}
|
||||
|
||||
else if (boardArray[row+reflector][kolumn+1] == temp)
|
||||
{
|
||||
cout<<"you hate your own team or something? you can't do that!"<<endl;
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
boardArray[row][kolumn] = '_';
|
||||
boardArray[row+reflector][kolumn+1] = temp;
|
||||
|
||||
changeTurns();
|
||||
displayBoard();
|
||||
}
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
cout<<"Unrecognized movetype!"<<endl;
|
||||
}
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
cout<<"Invalid piece!"<<endl;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
bool isThisMovePossible(int r, int c, string moveType)
|
||||
{
|
||||
char pieceToMove = boardArray[r][c];
|
||||
|
||||
if (pieceToMove != turn) //trying to move invalid piece
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
int reflector = 1;
|
||||
|
||||
if (pieceToMove == 'O')
|
||||
{
|
||||
reflector *= -1;
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
if (moveType == "FWD")
|
||||
{
|
||||
|
||||
if (boardArray[r+reflector][c] == '_')
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
else return false;
|
||||
|
||||
}
|
||||
|
||||
else if (moveType == "RIGHT")
|
||||
{
|
||||
if (boardArray[r+reflector][c+1] != pieceToMove && (r+reflector >= 0) && (r+reflector <= 7) && (c+1 <= 7) )
|
||||
{
|
||||
return true;
|
||||
}
|
||||
else return false;
|
||||
}
|
||||
|
||||
else if (moveType == "LEFT")
|
||||
{
|
||||
if (boardArray[r+reflector][c-1] != pieceToMove && (r+reflector >= 0) && (r+reflector <= 7) && (c+1 >= 0) )
|
||||
{
|
||||
return true;
|
||||
}
|
||||
else return false;
|
||||
}
|
||||
|
||||
else return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
bool isThisAPriorityMove(moves inputMove) //assumes given move is valid!
|
||||
{
|
||||
char pieceToMove = boardArray[inputMove.row][inputMove.column];
|
||||
cout<<"pieceToMove: "<<pieceToMove<<endl;
|
||||
|
||||
if (pieceToMove == 'X')
|
||||
{
|
||||
if (inputMove.moveType == "FWD")
|
||||
{
|
||||
if (boardArray[inputMove.row + 1][inputMove.column] == 'O')
|
||||
{
|
||||
return true;
|
||||
}
|
||||
else return false;
|
||||
}
|
||||
|
||||
else if (inputMove.moveType == "LEFT")
|
||||
{
|
||||
if (boardArray[inputMove.row + 1][inputMove.column - 1] == 'O')
|
||||
{
|
||||
return true;
|
||||
}
|
||||
else return false;
|
||||
}
|
||||
else if (inputMove.moveType == "RIGHT");
|
||||
{
|
||||
if (boardArray[inputMove.row + 1][inputMove.column + 1] == 'O')
|
||||
{
|
||||
return true;
|
||||
}
|
||||
else return false;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
else if (pieceToMove == 'O')
|
||||
{
|
||||
if (inputMove.moveType == "FWD")
|
||||
{
|
||||
if (boardArray[inputMove.row - 1][inputMove.column] == 'X')
|
||||
{
|
||||
return true;
|
||||
}
|
||||
else return false;
|
||||
}
|
||||
|
||||
else if (inputMove.moveType == "LEFT")
|
||||
{
|
||||
if (boardArray[inputMove.row - 1][inputMove.column - 1] == 'X')
|
||||
{
|
||||
return true;
|
||||
}
|
||||
else return false;
|
||||
}
|
||||
else if (inputMove.moveType == "RIGHT");
|
||||
{
|
||||
if (boardArray[inputMove.row - 1][inputMove.column + 1] == 'X')
|
||||
{
|
||||
return true;
|
||||
}
|
||||
else return false;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
vector<moves> viewPossibleMoves()
|
||||
{
|
||||
vector<moves> output;
|
||||
|
||||
for (int r = 0; r < 8; ++r)
|
||||
{
|
||||
for (int c = 0; c < 8; ++c)
|
||||
{
|
||||
if (boardArray[r][c] == turn)
|
||||
{
|
||||
|
||||
if (isThisMovePossible(r,c,"FWD"))
|
||||
{
|
||||
moves temp(8-r,intToCharColumn(c+1),"FWD");
|
||||
output.push_back(temp);
|
||||
}
|
||||
|
||||
if (isThisMovePossible(r,c,"LEFT"))
|
||||
{
|
||||
moves temp(8-r,intToCharColumn(c+1),"LEFT");
|
||||
output.push_back(temp);
|
||||
}
|
||||
|
||||
if (isThisMovePossible(r,c,"RIGHT"))
|
||||
{
|
||||
moves temp(8-r,intToCharColumn(c+1),"RIGHT");
|
||||
output.push_back(temp);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// cout<<"\nnumber of possible choices: "<<output.size()<<endl; //for debugging purposes
|
||||
// for (int i = 0; i < output.size(); ++i)
|
||||
// {
|
||||
// output[i].display();
|
||||
// }
|
||||
|
||||
|
||||
cout<<"\nnumber of possible choices: "<<output.size()<<endl; //for debugging purposes
|
||||
for (int i = 0; i < output.size(); ++i)
|
||||
{
|
||||
output[i].display();
|
||||
if (isThisAPriorityMove(output[i]))
|
||||
{
|
||||
cout<<"a priority move"<<endl;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
return output;
|
||||
}
|
||||
|
||||
|
||||
|
||||
vector<moves> viewPrioritizedMoves()
|
||||
{
|
||||
vector<moves> output;
|
||||
|
||||
for (int r = 0; r < 8; ++r)
|
||||
{
|
||||
for (int c = 0; c < 8; ++c)
|
||||
{
|
||||
if (boardArray[r][c] == turn)
|
||||
{
|
||||
|
||||
if (isThisMovePossible(r,c,"FWD"))
|
||||
{
|
||||
moves temp(8-r,intToCharColumn(c+1),"FWD");
|
||||
output.push_back(temp);
|
||||
}
|
||||
|
||||
if (isThisMovePossible(r,c,"LEFT"))
|
||||
{
|
||||
moves temp(8-r,intToCharColumn(c+1),"LEFT");
|
||||
output.push_back(temp);
|
||||
}
|
||||
|
||||
if (isThisMovePossible(r,c,"RIGHT"))
|
||||
{
|
||||
moves temp(8-r,intToCharColumn(c+1),"RIGHT");
|
||||
output.push_back(temp);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return output;
|
||||
}
|
||||
|
||||
|
||||
void easyAI()
|
||||
{
|
||||
|
||||
//1) see all possible movements
|
||||
|
||||
vector<moves> listOfMoves = viewPossibleMoves();
|
||||
|
||||
//2) pick a movement
|
||||
|
||||
srand(time(NULL));
|
||||
int randomChoice = rand() % (listOfMoves.size()-1) - 0; // choose a move betwen listOfMoves[0] to last element
|
||||
|
||||
//3) execute movement
|
||||
|
||||
int temp = randomChoice;
|
||||
|
||||
move(listOfMoves[randomChoice]);
|
||||
|
||||
//cout<<"\n\nMove executed by AI: "<<listOfMoves[temp].column<<" "<<listOfMoves[temp].row<<" "<<listOfMoves[temp].moveType<<endl; uncomment for debugging purposes
|
||||
|
||||
}
|
||||
|
||||
|
||||
}; //end Board class
|
||||
|
||||
vector<Board> record;
|
||||
|
||||
void undo(Board& tablero)
|
||||
{
|
||||
if (record.size() < 2)
|
||||
{
|
||||
cout<<"nothing to undo"<<endl;
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
for (int r = 0; r < 8; ++r)
|
||||
{
|
||||
for (int k = 0; k < 8; ++k)
|
||||
{
|
||||
tablero.modifyAt(r,k,(record[record.size()-2]).elementAt(r,k));
|
||||
}
|
||||
}
|
||||
record.pop_back();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void interpret(string input, Board& tablero) //determines what kind of command its input is
|
||||
{
|
||||
input = myToUpper(input);
|
||||
|
||||
if (input == "UNDO")
|
||||
{
|
||||
undo(tablero);
|
||||
}
|
||||
|
||||
else if (input == "DISPLAYRECORD") //for debugging purposes
|
||||
{
|
||||
cout<<"record: "<<endl;
|
||||
cout<<record.size();
|
||||
for (int i = 0; i < record.size(); ++i)
|
||||
{
|
||||
record[i].displayBoard();
|
||||
}
|
||||
cout<<"---------------------------------------------------END DISPLAY RECORD------------------------"<<endl;
|
||||
}
|
||||
|
||||
else tablero.move(input);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
void displayPossibleMoves(vector<moves> input)
|
||||
{
|
||||
cout<<"\n\nList of possible Moves:"<<endl;
|
||||
for (int i = 0; i < input.size(); ++i)
|
||||
{
|
||||
cout<<"possible move: "<<input[i].row<<" "<<input[i].column<<" "<<input[i].moveType<<endl;
|
||||
}
|
||||
}
|
||||
|
||||
void snapshot(vector<Board>& inputVec, Board inputBoard)
|
||||
{
|
||||
if (inputVec.size() == 10)
|
||||
{
|
||||
inputVec.erase(inputVec.begin());
|
||||
}
|
||||
|
||||
else if (inputVec.size() > 10)
|
||||
{
|
||||
cout<<"QUEUE OVERFLOW!"<<endl;
|
||||
}
|
||||
|
||||
|
||||
inputVec.push_back(inputBoard);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
int main()
|
||||
{
|
||||
|
||||
cout<<"\n----------------------------"<<endl;
|
||||
cout<<"Welcome to Breakthrough\n"<<endl;
|
||||
cout<<"-----------------------------\n\n"<<endl;
|
||||
|
||||
cout<<"1. Play agains AI?"<<endl;
|
||||
cout<<"2. Play against a human?"<<endl;
|
||||
cout<<"Enter choice: "<<endl;
|
||||
|
||||
int choice;
|
||||
cin>>choice;
|
||||
|
||||
if (choice == 1) cout<<"playing with AI..."<<endl;
|
||||
else cout<<"playing with human..."<<endl;
|
||||
|
||||
Board b;
|
||||
|
||||
string move;
|
||||
|
||||
bool gameOver = false;
|
||||
|
||||
snapshot(record,b);
|
||||
|
||||
while (gameOver != true)
|
||||
{
|
||||
gameOver = b.isGameOver();
|
||||
|
||||
while(b.getTurn() == 'O' )
|
||||
{
|
||||
b.displayBoard();
|
||||
cout<<"\nEnter command: ";
|
||||
cin>>move;
|
||||
interpret(move,b);
|
||||
}
|
||||
|
||||
|
||||
vector<moves> possibleMoves = b.viewPossibleMoves();
|
||||
//displayPossibleMoves(possibleMoves); for debugging purposes - AI
|
||||
|
||||
if (choice == 1)
|
||||
{
|
||||
b.easyAI();
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
while(b.getTurn() == 'X' )
|
||||
{
|
||||
b.displayBoard();
|
||||
cout<<"\nEnter command: ";
|
||||
cin>>move;
|
||||
interpret(move,b);
|
||||
}
|
||||
}
|
||||
|
||||
//b.snapshot();
|
||||
gameOver = b.isGameOver();
|
||||
|
||||
snapshot(record,b);
|
||||
}
|
||||
|
||||
//for debugging purposes
|
||||
cout<<"Record:"<<endl;
|
||||
|
||||
|
||||
cout<<record.size();
|
||||
for (int i = 0; i < record.size(); ++i)
|
||||
{
|
||||
record[i].displayBoard();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
Reference in a new issue