Update Board.cpp
This commit is contained in:
parent
6a94a23425
commit
6355f7ad56
1 changed files with 30 additions and 10 deletions
40
Board.cpp
40
Board.cpp
|
@ -498,9 +498,8 @@ void Board::displayPossibleMoves(vector<moves> input)
|
|||
}
|
||||
}
|
||||
|
||||
void Board::undo(Board& tablero)
|
||||
void Board::undo()
|
||||
{
|
||||
vector<Board> record;
|
||||
|
||||
if (record.size() < 2)
|
||||
{
|
||||
|
@ -509,11 +508,14 @@ void Board::undo(Board& tablero)
|
|||
|
||||
else
|
||||
{
|
||||
cout<<"BAZINGA"<<endl;
|
||||
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));
|
||||
char shamwow = record[record.size()-2].elementAt(r,k);
|
||||
//boardArray.modifyAt(r,k,shamwow);
|
||||
boardArray[r][k] = shamwow;
|
||||
}
|
||||
}
|
||||
record.pop_back();
|
||||
|
@ -525,9 +527,9 @@ void Board::interpret(string input, Board& tablero) //determines what kind of co
|
|||
vector<Board> record;
|
||||
input = myToUpper(input);
|
||||
|
||||
if (input == "UNDO")
|
||||
if (input[0] == 'U')
|
||||
{
|
||||
undo(tablero);
|
||||
undo();
|
||||
}
|
||||
|
||||
else if (input == "DISPLAYRECORD") //for debugging purposes
|
||||
|
@ -544,21 +546,31 @@ void Board::interpret(string input, Board& tablero) //determines what kind of co
|
|||
else tablero.move(input);
|
||||
}
|
||||
|
||||
void Board::snapshot(vector<Board>& inputVec, Board inputBoard)
|
||||
void Board::snapshot()
|
||||
{
|
||||
if (inputVec.size() == 10)
|
||||
if (record.size() == 10)
|
||||
{
|
||||
inputVec.erase(inputVec.begin());
|
||||
record.erase(record.begin());
|
||||
}
|
||||
|
||||
else if (inputVec.size() > 10)
|
||||
else if (record.size() > 10)
|
||||
{
|
||||
cout<<"QUEUE OVERFLOW!"<<endl;
|
||||
}
|
||||
|
||||
simpleBoard boardToPush;
|
||||
|
||||
inputVec.push_back(inputBoard);
|
||||
for (int r = 0; r < 8; ++r)
|
||||
{
|
||||
for (int k = 0; k < 8; ++k)
|
||||
{
|
||||
boardToPush.modifyAt(r,k,boardArray[r][k]);
|
||||
}
|
||||
}
|
||||
|
||||
record.push_back(boardToPush);
|
||||
}
|
||||
|
||||
|
||||
//move this to its own file
|
||||
void Board::easyAI()
|
||||
|
@ -582,3 +594,11 @@ void Board::easyAI()
|
|||
//cout<<"\n\nMove executed by AI: "<<listOfMoves[temp].column<<" "<<listOfMoves[temp].row<<" "<<listOfMoves[temp].moveType<<endl; uncomment for debugging purposes
|
||||
|
||||
}
|
||||
|
||||
void Board::displayRecord()
|
||||
{
|
||||
for (int i = 0; i < record.size(); ++i)
|
||||
{
|
||||
record[i].display();
|
||||
}
|
||||
}
|
||||
|
|
Reference in a new issue