43 lines
No EOL
771 B
C++
Executable file
43 lines
No EOL
771 B
C++
Executable file
#include <iostream>
|
|
#include <vector>
|
|
#include "MNode.h"
|
|
|
|
using namespace std;
|
|
|
|
MNode::MNode(){
|
|
children.clear();
|
|
minimax_val = -1;
|
|
}
|
|
|
|
MNode::MNode(Board s, moves m, int mmval){
|
|
state = s;
|
|
mvs = m;
|
|
minimax_val = mmval;
|
|
}
|
|
|
|
MNode::MNode(const MNode& n){
|
|
children = n.getChildren();
|
|
minimax_val = n.getMMVal();
|
|
}
|
|
|
|
void MNode::setMMVal(int mmval) {
|
|
minimax_val = mmval;
|
|
}
|
|
|
|
bool MNode::hasChildren(){
|
|
if (children.size() != 0)
|
|
return true;
|
|
else
|
|
return false;
|
|
}
|
|
|
|
void printTree(int depth, MNode* n){
|
|
vector<MNode*> children;
|
|
cout << "depth " << depth << " : " << n->getMMVal() << "\n";
|
|
children = n->getChildren();
|
|
|
|
//print out root
|
|
for (int i = 0; i < children.size(); ++i){
|
|
printTree(++depth, children[i]);
|
|
}
|
|
} |