IDS使用宏控制并打印计算时间

This commit is contained in:
CalciteM 2019-06-30 23:49:45 +08:00
parent 191e507600
commit 2113b75206
2 changed files with 18 additions and 1 deletions

View File

@ -28,6 +28,8 @@
#define DRAW_SEAT_NUMBER
#endif
#define IDS_SUPPORT
#define SAVE_CHESSBOOK_WHEN_ACTION_NEW_TRIGGERED
// #define DONOT_PLAY_WIN_SOUND

View File

@ -8,6 +8,7 @@
#include <cmath>
#include <time.h>
#include <Qdebug>
#include <QTime>
NineChessAi_ab::NineChessAi_ab() :
rootNode(nullptr),
@ -430,15 +431,29 @@ int NineChessAi_ab::changeDepth(int originalDepth)
int NineChessAi_ab::alphaBetaPruning(int depth)
{
QTime time;
int value = 0;
int d = changeDepth(depth);
time.start();
#ifdef IDS_SUPPORT
// 深化迭代
for (int i = 2; i < d; i++) {
alphaBetaPruning(i, -INF_VALUE, INF_VALUE, rootNode);
}
return alphaBetaPruning(d, -INF_VALUE, INF_VALUE, rootNode);
qDebug() << "IDS Time: " << time.elapsed() / 1000.0 << "s";
#endif /* IDS_SUPPORT */
value = alphaBetaPruning(d, -INF_VALUE, INF_VALUE, rootNode);
qDebug() << "Total Time: " << time.elapsed() / 1000.0 << "s\n";
// 生成了 Alpha-Beta 树
return value;
}
int NineChessAi_ab::alphaBetaPruning(int depth, int alpha, int beta, Node *node)