From 944480d69b7112edf56572111d5108c943e37875 Mon Sep 17 00:00:00 2001 From: CalciteM Date: Sun, 4 Aug 2019 13:12:29 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=20pos2cp=20=E5=87=BD?= =?UTF-8?q?=E6=95=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- NineChess/src/aithread.cpp | 4 ++-- NineChess/src/config.h | 7 +++++++ NineChess/src/ninechess.cpp | 13 +++++-------- NineChess/src/ninechess.h | 2 +- 4 files changed, 15 insertions(+), 11 deletions(-) diff --git a/NineChess/src/aithread.cpp b/NineChess/src/aithread.cpp index cf0820f8..512543b9 100644 --- a/NineChess/src/aithread.cpp +++ b/NineChess/src/aithread.cpp @@ -128,12 +128,12 @@ void AiThread::run() if (ai_ab.alphaBetaPruning(aiDepth) == 3) { qDebug() << "Draw\n"; strCommand = "draw"; - QTimer::singleShot(500, this, &AiThread::emitCommand); + QTimer::singleShot(EMIT_COMMAND_DELAY, this, &AiThread::emitCommand); } else { strCommand = ai_ab.bestMove(); qDebug() << "Computer:" << strCommand << "\n"; if (strcmp(strCommand, "error!")) - QTimer::singleShot(500, this, &AiThread::emitCommand); + QTimer::singleShot(EMIT_COMMAND_DELAY, this, &AiThread::emitCommand); } #ifdef DEBUG_MODE diff --git a/NineChess/src/config.h b/NineChess/src/config.h index 70073ef3..4205c23c 100644 --- a/NineChess/src/config.h +++ b/NineChess/src/config.h @@ -22,8 +22,15 @@ #define CONFIG_H //#define DEBUG_MODE +//#define DEBUG_MODE_A +#ifdef DEBUG_MODE_A +#define EMIT_COMMAND_DELAY (0) +#define DONOT_PLAY_SOUND +#else #define RANDOM_MOVE +#define EMIT_COMMAND_DELAY (500) +#endif #define EVALUATE_ENABLE diff --git a/NineChess/src/ninechess.cpp b/NineChess/src/ninechess.cpp index d824f0d1..14465687 100644 --- a/NineChess/src/ninechess.cpp +++ b/NineChess/src/ninechess.cpp @@ -652,15 +652,12 @@ bool NineChess::getCurrentPiece(Player &player, int &number) return true; } -bool NineChess::pos2cp(const int pos, int &c, int &p) +void NineChess::pos2cp(const int pos, int &c, int &p) { - if (pos < POS_BEGIN || POS_END <= pos) - return false; - - c = pos / N_SEATS; - p = pos % N_SEATS + 1; - - return true; + //c = pos / N_SEATS; + //p = pos % N_SEATS + 1; + c = pos >> 3; + p = (pos & 0x07) + 1; } int NineChess::cp2pos(int c, int p) diff --git a/NineChess/src/ninechess.h b/NineChess/src/ninechess.h index 60d5fe11..b7192caf 100644 --- a/NineChess/src/ninechess.h +++ b/NineChess/src/ninechess.h @@ -493,7 +493,7 @@ protected: int addMills(int pos); // 将棋盘下标形式转化为第c圈,第p位,c和p下标都从1开始 - bool pos2cp(const int pos, int &c, int &p); + void pos2cp(const int pos, int &c, int &p); // 将第c圈,第p位转化为棋盘下标形式,c和p下标都从1开始 int cp2pos(int c, int p);