diff --git a/Board.cpp b/Board.cpp index b64e80d..12fb950 100644 --- a/Board.cpp +++ b/Board.cpp @@ -475,20 +475,20 @@ int Board::evaluate(char max, char min){ //check for taken conditions if (checkTaken(min)){ - val += 10; + val = val + 10; } if (checkTaken(max)){ - val -= 10; + val = val - 10; } //ultimate condition! if (isGameOver()){ if (whoWon() == max) - val = INT_MAX / 2; + val = val + 10; else - val = INT_MIN / 2; + val = val - 10; } //cout << "val: " << val << "\n"; diff --git a/Engine.cpp b/Engine.cpp index 5ba8159..3478067 100644 --- a/Engine.cpp +++ b/Engine.cpp @@ -65,6 +65,7 @@ void Engine::userGame(int difficulty){ b->resetTaken(); b->setValidFalse(); } + b->displayBoard(); } while(b->getTurn() == 'X' ){ @@ -110,9 +111,13 @@ void Engine::AIGame(int difficulty){ } void Engine::AI(int depth){ + if (depth == -1) + depth = INT_MAX; + Board* state = new Board(*b); moves m; - MNode* root = new MNode(*state, m, 0); + MNode* root = new MNode(*state, m, 0); + this->resetAB(); createMMTree(root, depth, 1); m = evaluateMMTree(root); @@ -227,4 +232,9 @@ int Engine::evaluateMMBranch(MNode* node, int max, int min){ min = node->getMMVal(); return max; +} + +void Engine::resetAB(){ + alpha = INT_MIN; + beta = INT_MAX; } \ No newline at end of file diff --git a/Engine.h b/Engine.h index 6cf8d36..3899791 100644 --- a/Engine.h +++ b/Engine.h @@ -20,4 +20,5 @@ public: void createMMTree(MNode* node, int depth, int alt); moves evaluateMMTree(MNode* node); int evaluateMMBranch(MNode* node, int max, int min); + void resetAB(); };