tree: 解决开启 DEBUG_AB_TREE 宏后的编译和段错误问题

This commit is contained in:
Calcitem 2019-10-07 18:33:46 +08:00
parent 727063d6b0
commit 409cd53517
3 changed files with 7 additions and 7 deletions

View File

@ -333,7 +333,7 @@ void MoveList::create()
#ifdef DEBUG_MODE #ifdef DEBUG_MODE
int sum = 0; int sum = 0;
for (int i = 0; i < Board::N_LOCATIONS; i++) { for (int i = 0; i < SQ_EXPANDED_COUNT; i++) {
loggerDebug("/* %d */ {", i); loggerDebug("/* %d */ {", i);
for (int j = 0; j < DIRECTIONS_COUNT; j++) { for (int j = 0; j < DIRECTIONS_COUNT; j++) {
if (j == DIRECTIONS_COUNT - 1) if (j == DIRECTIONS_COUNT - 1)

View File

@ -201,19 +201,19 @@ struct AIAlgorithm::Node *AIAlgorithm::addNode(
char cmd[32] = { 0 }; char cmd[32] = { 0 };
if (move < 0) { if (move < 0) {
tempGame.position.board.squareToPolar(-move, r, s); tempGame.position.board.squareToPolar(static_cast<square_t>(-move), r, s);
sprintf(cmd, "-(%1u,%1u)", r, s); sprintf(cmd, "-(%1u,%1u)", r, s);
} else if (move & 0x7f00) { } else if (move & 0x7f00) {
int r1, s1; int r1, s1;
tempGame.position.board.squareToPolar(move >> 8, r1, s1); tempGame.position.board.squareToPolar(static_cast<square_t>(move >> 8), r1, s1);
tempGame.position.board.squareToPolar(move & 0x00ff, r, s); tempGame.position.board.squareToPolar(static_cast<square_t>(move & 0x00ff), r, s);
sprintf(cmd, "(%1u,%1u)->(%1u,%1u)", r1, s1, r, s); sprintf(cmd, "(%1u,%1u)->(%1u,%1u)", r1, s1, r, s);
} else { } else {
tempGame.position.board.squareToPolar(move & 0x007f, r, s); tempGame.position.board.squareToPolar(static_cast<square_t>(move & 0x007f), r, s);
sprintf(cmd, "(%1u,%1u)", r, s); sprintf(cmd, "(%1u,%1u)", r, s);
} }
newNode->cmd = cmd; strcpy(newNode->cmd, cmd);
#endif // DEBUG_AB_TREE #endif // DEBUG_AB_TREE
if (parent) { if (parent) {

View File

@ -76,7 +76,7 @@ public:
#ifdef DEBUG_AB_TREE #ifdef DEBUG_AB_TREE
size_t id; // 结点编号 size_t id; // 结点编号
string cmd; char cmd[32];
int depth; // 深度 int depth; // 深度
bool evaluated; // 是否评估过局面 bool evaluated; // 是否评估过局面
int alpha; // 当前搜索结点走棋方搜索到的最好值,任何比它小的值对当前结点的走棋方都没有意义。当函数递归时 Alpha 和 Beta 不但取负数而且要交换位置 int alpha; // 当前搜索结点走棋方搜索到的最好值,任何比它小的值对当前结点的走棋方都没有意义。当函数递归时 Alpha 和 Beta 不但取负数而且要交换位置