tree DONE, no ab pruning
This commit is contained in:
parent
5f4c6c2539
commit
01b8e2c06b
3 changed files with 4 additions and 11 deletions
|
@ -541,9 +541,6 @@ void Board::snapshot(vector<Board>& inputVec, Board inputBoard){
|
||||||
int Board::evaluate(char max){
|
int Board::evaluate(char max){
|
||||||
int val = 0;
|
int val = 0;
|
||||||
|
|
||||||
srand(time(NULL));
|
|
||||||
val = rand() % 100 + 1;
|
|
||||||
/*
|
|
||||||
if (max == 'X'){
|
if (max == 'X'){
|
||||||
val += (xpieces.size() - opieces.size());
|
val += (xpieces.size() - opieces.size());
|
||||||
}
|
}
|
||||||
|
@ -555,7 +552,7 @@ int Board::evaluate(char max){
|
||||||
else {
|
else {
|
||||||
cout << "Error in evaluate: unidentified max, must be either 'X' or 'O'.\n";
|
cout << "Error in evaluate: unidentified max, must be either 'X' or 'O'.\n";
|
||||||
}
|
}
|
||||||
*/
|
|
||||||
return val;
|
return val;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -71,15 +71,14 @@ void Engine::AI(int depth){
|
||||||
MNode* root = new MNode(*state, m, 0);
|
MNode* root = new MNode(*state, m, 0);
|
||||||
createMMTree(root, depth);
|
createMMTree(root, depth);
|
||||||
m = evaluateMMTree(root);
|
m = evaluateMMTree(root);
|
||||||
cout << "\n";
|
|
||||||
/*
|
/*
|
||||||
printTree(0, root);
|
printTree(0, root);
|
||||||
cout << "\n";
|
cout << "\n";
|
||||||
|
cout << "AI move: (" << m.row << ", " << m.column << "): " << m.moveType << "\n";
|
||||||
*/
|
*/
|
||||||
|
|
||||||
vector<moves> listOfMoves = b->viewPossibleMoves();
|
b->move(m);
|
||||||
b->move(listOfMoves[0]);
|
|
||||||
|
|
||||||
b->changeTurns();
|
b->changeTurns();
|
||||||
b->displayBoard();
|
b->displayBoard();
|
||||||
}
|
}
|
||||||
|
@ -118,7 +117,6 @@ moves Engine::evaluateMMTree(MNode* node){
|
||||||
|
|
||||||
for (auto &c : children){
|
for (auto &c : children){
|
||||||
val = evaluateMMBranch(c, 0);
|
val = evaluateMMBranch(c, 0);
|
||||||
|
|
||||||
if(val > max){
|
if(val > max){
|
||||||
temp = c;
|
temp = c;
|
||||||
max = val;
|
max = val;
|
||||||
|
|
2
test.cpp
2
test.cpp
|
@ -6,6 +6,4 @@ int main()
|
||||||
{
|
{
|
||||||
Engine e;
|
Engine e;
|
||||||
e.startGame();
|
e.startGame();
|
||||||
|
|
||||||
//COMPILES BUT EVERYTHING IS PRINTING FIRST MOVE
|
|
||||||
}
|
}
|
||||||
|
|
Reference in a new issue