控制台打印第一级子树的值

This commit is contained in:
CalciteM 2019-06-23 00:00:38 +08:00
parent f25fbc21ec
commit 77c9ad476e
2 changed files with 25 additions and 1 deletions

View File

@ -73,7 +73,7 @@ void AiThread::run()
ai_ab.alphaBetaPruning(aiDepth);
const char *str = ai_ab.bestMove();
qDebug() << str;
qDebug() << "Computer:" << str;
if (strcmp(str, "error!"))
emit command(str);
#ifdef DEBUG

View File

@ -7,6 +7,7 @@
#include "ninechessai_ab.h"
#include <cmath>
#include <time.h>
#include <Qdebug>
NineChessAi_ab::NineChessAi_ab() :
rootNode(nullptr),
@ -369,10 +370,33 @@ const char *NineChessAi_ab::bestMove()
{
if ((rootNode->children).size() == 0)
return "error!";
qDebug() << "31 ----- 24 ----- 25";
qDebug() << "| \ | / |";
qDebug() << "| 23 -- 16 -- 17 |";
qDebug() << "| | \ | / | |";
qDebug() << "| | 15 08 09 | |";
qDebug() << "30-22-14 10-18-26";
qDebug() << "| | 13 12 11 | |";
qDebug() << "| | / | \ | |";
qDebug() << "| 21 -- 20 -- 19 |";
qDebug() << "| / | \ |";
qDebug() << "29 ----- 28 ----- 27";
qDebug() << "";
string moves = "";
for (auto child : rootNode->children) {
if (child->value == rootNode->value)
qDebug() << child->move << ":" << child->value << "(*)";
else
qDebug() << child->move << ":" << child->value;
}
for (auto child : rootNode->children) {
if (child->value == rootNode->value)
return move2string(child->move);
}
return "error!";
}