diff --git a/Board.cpp b/Board.cpp index a64bc7a..d01b709 100755 --- a/Board.cpp +++ b/Board.cpp @@ -201,13 +201,13 @@ char Board::intToCharColumn(int input){ } void Board::move(string inputMove){ - moves jugada = parse(inputMove); - move(jugada); + moves m = parse(inputMove); + move(m); } -void Board::move(moves jugada){ - int row = 8 - (jugada.row); - int column = charToIntColumn(jugada.column); +void Board::move(moves m){ + int row = 8 - (m.row); + int column = charToIntColumn(m.column); if (row > 8 || row < 0 || column > 8 || column < 0) { cout<<"ERROR: index out of bound."<moveFwd(); } - else if (jugada.moveType == "LEFT") { + else if (m.moveType == "LEFT") { //add error checking piece->moveLeft(); } - else if (jugada.moveType == "RIGHT") { + else if (m.moveType == "RIGHT") { //add error checking piece->moveRight(); } @@ -262,21 +268,21 @@ bool Board::isThisMovePossible(int r, int c, string moveType){ reflector *= -1; if (moveType == "FWD"){ - if (isPiece(r+reflector, c)) + if (!isPiece(r + reflector, c)) return true; else return false; } else if (moveType == "RIGHT"){ - if (isPiece(r+reflector, c+1) && (r+reflector >= 0) && (r+reflector <= 7) && (c+1 <= 7)) + if (!isPiece(r+reflector, c+1) && (r+reflector >= 0) && (r+reflector <= 7) && (c+1 <= 7)) return true; else return false; } else if (moveType == "LEFT"){ - if (isPiece(r+reflector, c+1) && (r+reflector >= 0) && (r+reflector <= 7) && (c+1 >= 0)) + if (!isPiece(r+reflector, c+1) && (r+reflector >= 0) && (r+reflector <= 7) && (c+1 >= 0)) return true; else return false; @@ -314,7 +320,7 @@ vector Board::viewPossibleMoves(){ } } - else { + else if (turn == 'X') { for (int i = 0; i < opieces.size(); ++i){ r = opieces[i]->getX(); c = opieces[i]->getY(); diff --git a/Engine.cpp b/Engine.cpp index 23a3161..45c2229 100755 --- a/Engine.cpp +++ b/Engine.cpp @@ -60,6 +60,7 @@ void Engine::easyAI() int randomChoice = rand() % (listOfMoves.size()-1) - 0; int temp = randomChoice; + cout << "easy AI move: " << listOfMoves[randomChoice].row << listOfMoves[randomChoice].column << listOfMoves[randomChoice].moveType << "\n"; b->move(listOfMoves[randomChoice]); b->changeTurns(); } @@ -93,7 +94,7 @@ void Engine::AI(){ } moves Engine::minMax(Board* temp, moves m, int c){ - //testing purposes only + //testing purposes only, c = finite depth if (c > 5){ return m; } diff --git a/test.cpp b/test.cpp index 993ed73..88d7f86 100755 --- a/test.cpp +++ b/test.cpp @@ -6,8 +6,8 @@ using namespace std; int main() { //board testing - //Board b; - + Board b; + //engine testing Engine e; e.startGame();