Stable AI w/o error printing
This commit is contained in:
parent
63c2b52b5a
commit
c3cf43fc00
4 changed files with 12 additions and 10 deletions
14
Board.cpp
14
Board.cpp
|
@ -80,7 +80,7 @@ void Board::isTaken(int r, int c) {
|
|||
for(int x = 0; x < opieces.size(); ++x) {
|
||||
if (opieces[x]->getX() == r && opieces[x]->getY() == c) {
|
||||
opieces.erase(opieces.begin() + x);
|
||||
cout << "otaken set to TRUE\n";
|
||||
//cout << "otaken set to TRUE\n";
|
||||
otaken = true;
|
||||
}
|
||||
}
|
||||
|
@ -89,7 +89,7 @@ void Board::isTaken(int r, int c) {
|
|||
for(int x = 0; x < xpieces.size(); ++x) {
|
||||
if (xpieces[x]->getX() == r && xpieces[x]->getY() == c) {
|
||||
xpieces.erase(xpieces.begin() + x);
|
||||
cout << "xtaken set to TRUE\n";
|
||||
//cout << "xtaken set to TRUE\n";
|
||||
xtaken = true;
|
||||
}
|
||||
}
|
||||
|
@ -582,16 +582,16 @@ int Board::evaluate(char max, char min){
|
|||
|
||||
val += 2 * (maxPieces.size() - minPieces.size());
|
||||
|
||||
cout << (checkTaken(max)) << "\n";
|
||||
cout << (checkTaken(min)) << "\n";
|
||||
//cout << (checkTaken(max)) << "\n";
|
||||
//cout << (checkTaken(min)) << "\n";
|
||||
//check for taken conditions
|
||||
if (checkTaken(min)){
|
||||
cout << "adding 10 to val\n";
|
||||
//cout << "adding 10 to val\n";
|
||||
val += 10;
|
||||
}
|
||||
|
||||
if (checkTaken(max)){
|
||||
cout << "subtracting 10 from val\n";
|
||||
//cout << "subtracting 10 from val\n";
|
||||
val -= 10;
|
||||
}
|
||||
|
||||
|
@ -604,7 +604,7 @@ int Board::evaluate(char max, char min){
|
|||
val = INT_MIN / 2;
|
||||
}
|
||||
|
||||
cout << "val: " << val << "\n";
|
||||
//cout << "val: " << val << "\n";
|
||||
return val;
|
||||
}
|
||||
|
||||
|
|
|
@ -101,7 +101,7 @@ void Engine::AI(int depth){
|
|||
createMMTree(root, depth, 1);
|
||||
m = evaluateMMTree(root);
|
||||
|
||||
printTree(0, root);
|
||||
//printTree(0, root);
|
||||
|
||||
b->move(m);
|
||||
b->changeTurns();
|
||||
|
@ -125,12 +125,12 @@ void Engine::createMMTree(MNode* node, int depth, int alt){
|
|||
max = current.getTurn();
|
||||
current.changeTurns();
|
||||
min = current.getTurn();
|
||||
|
||||
/*
|
||||
if (current.checkTaken('X'))
|
||||
cout << "xtaken true\n";
|
||||
if (current.checkTaken('O'))
|
||||
cout << "otaken true\n";
|
||||
|
||||
*/
|
||||
temp = new MNode(current, listOfMoves[i], current.evaluate(max, min));
|
||||
|
||||
if (alt == 1)
|
||||
|
|
1
Engine.h
1
Engine.h
|
@ -8,6 +8,7 @@ using namespace std;
|
|||
class Engine {
|
||||
Board* b;
|
||||
|
||||
|
||||
public:
|
||||
Engine();
|
||||
Board* getBoard() { return b; }
|
||||
|
|
1
test.cpp
1
test.cpp
|
@ -4,6 +4,7 @@ using namespace std;
|
|||
|
||||
int main()
|
||||
{
|
||||
Board b;
|
||||
Engine e;
|
||||
e.startGame();
|
||||
}
|
||||
|
|
Reference in a new issue