From 67a2997b8c74bd1c6e96f0a6ad31a76472fee5ac Mon Sep 17 00:00:00 2001 From: Rebecca Schofield Date: Mon, 26 Oct 2015 17:08:48 -0500 Subject: [PATCH] updating NOT STABLE --- Board.cpp | 117 ++++------------------------------------------------- Engine.cpp | 39 ++++++++++++++++-- Engine.h | 2 +- 3 files changed, 45 insertions(+), 113 deletions(-) diff --git a/Board.cpp b/Board.cpp index d407bd7..1b161d2 100755 --- a/Board.cpp +++ b/Board.cpp @@ -143,113 +143,7 @@ char Board::intToCharColumn(int input) //converts column number to int void Board::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 in move()!"< listOfMoves = b->viewPossibleMoves(); - // + Board* temp = b; + if (temp->getTurn() != 'X'){ + temp->changeTurns(); + } + //temp->changeTurns(); + //cout << "after: " << temp->getTurn() << "\n"; + + //only doing 1 branch right now because testing + /*for (int i = 0; i < listOfMoves.size(); ++i){ + minMax(temp, listOfMoves[i]); + }*/ + minMax(temp, listOfMoves[0]); + + b->move(listOfMoves[0]); + cout << "----------------------END AI FUNCTION----------------------\n"; } -void Engine::minMax(){ - //do more things here +void Engine::minMax(Board* temp, moves m){ + if (temp->isGameOver() == true){ + cout << "END OF PATH REACHED\n"; + return; + } + + else { + + cout << "m.row: " << m.row << "\n"; + cout << "charToIntColumn(m.column): " << temp->charToIntColumn(m.column) << "\n"; + cout << "m.moveType: " << m.moveType << "\n"; + cout << "temp->isThisMovePossible(stuff): " << temp->isThisMovePossible(m.row, temp->charToIntColumn(m.column), m.moveType) << "\n\n\n"; + + vector listOfMoves = temp->viewPossibleMoves(); + /*for (int i = 0; i < listOfMoves.size(); ++i){ + minMax(temp, listOfMoves[i]); + }*/ + + temp->displayBoard(); + } } \ No newline at end of file diff --git a/Engine.h b/Engine.h index 8baa665..4011d23 100755 --- a/Engine.h +++ b/Engine.h @@ -12,5 +12,5 @@ public: void startGame(); void easyAI(); void AI(); - void minMax(); + void minMax(Board* temp, moves m); }; \ No newline at end of file