This commit is contained in:
Rebecca Schofield 2015-11-03 21:41:07 -06:00
parent f5ba309a6e
commit 39c2da093a
3 changed files with 16 additions and 5 deletions

View file

@ -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";

View file

@ -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;
}

View file

@ -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();
};