Stable AI w/o error printing

This commit is contained in:
Rebecca Schofield 2015-11-02 16:42:47 -06:00
parent 63c2b52b5a
commit c3cf43fc00
4 changed files with 12 additions and 10 deletions

View file

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

View file

@ -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)

View file

@ -8,6 +8,7 @@ using namespace std;
class Engine {
Board* b;
public:
Engine();
Board* getBoard() { return b; }

View file

@ -4,6 +4,7 @@ using namespace std;
int main()
{
Board b;
Engine e;
e.startGame();
}