43 lines
774 B
C++
43 lines
774 B
C++
![]() |
#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, const MNode& n){
|
||
|
vector<MNode*> children;
|
||
|
cout << "depth " << depth << " :" << n.getMMVal() << " ";
|
||
|
children = n.getChildren();
|
||
|
|
||
|
//print out root
|
||
|
for (int i = 0; i < children.size(); ++i){
|
||
|
printTree(++depth, *children[i]);
|
||
|
}
|
||
|
}
|