diff --git a/NineChess/src/aithread.cpp b/NineChess/src/aithread.cpp index 78de87bf..a0c749de 100644 --- a/NineChess/src/aithread.cpp +++ b/NineChess/src/aithread.cpp @@ -132,9 +132,10 @@ void AiThread::run() QTimer::singleShot(EMIT_COMMAND_DELAY, this, &AiThread::emitCommand); } else { strCommand = ai_ab.bestMove(); - qDebug() << "Computer:" << strCommand << "\n"; - if (strcmp(strCommand, "error!") != 0) + if (strCommand && strcmp(strCommand, "error!") != 0) { + qDebug() << "Computer:" << strCommand << "\n"; QTimer::singleShot(EMIT_COMMAND_DELAY, this, &AiThread::emitCommand); + } } #ifdef DEBUG_MODE diff --git a/NineChess/src/ninechessai_ab.cpp b/NineChess/src/ninechessai_ab.cpp index fcc38464..23710752 100644 --- a/NineChess/src/ninechessai_ab.cpp +++ b/NineChess/src/ninechessai_ab.cpp @@ -1113,6 +1113,10 @@ const char* NineChessAi_ab::bestMove() #endif //qDebug() << "sizeof(Node) = " << sizeof(Node); + if (bestMoves.empty()) { + return nullptr; + } + return move2string(bestMoves[0]->move); }