优化 pos2cp 函数

This commit is contained in:
CalciteM 2019-08-04 13:12:29 +08:00
parent 2ebb866685
commit 944480d69b
4 changed files with 15 additions and 11 deletions

View File

@ -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

View File

@ -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

View File

@ -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)

View File

@ -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);