将蒙特卡洛树打印出来,方面调试,代码如下:
void PrintNode(int indent, Node* node)
{
while (--indent >= 0)
std::cout << " ";
std::cout << node->win << "/" << node->visit << "[" << node->movement.player << "](" << node->movement.x << "," << node->movement.y << ")\n";
}
void PrintNodeChildren(int indent, Node* node)
{
Node *work;
work = node->child;
while(work!=NULL){
PrintNode(indent, work);
PrintNodeChildren(indent + 1, work);
work=work->brother;
}
}
void Print(Node* root)
{
int indent = 0;
PrintNode(indent, root);
PrintNodeChildren(indent + 1, root);
}