精简 place() 函数

This commit is contained in:
Calcitem Team 2019-08-11 20:56:01 +08:00
parent 323a1ab8ea
commit 01bb610351
1 changed files with 70 additions and 82 deletions

View File

@ -727,10 +727,7 @@ bool NineChess::place(int pos, long time_p, bool cp)
// 如果决出胜负
if (win()) {
if (cp == true) {
setTips();
}
return true;
goto out;
}
n = addMills(currentPos);
@ -757,10 +754,7 @@ bool NineChess::place(int pos, long time_p, bool cp)
// 再决胜负
if (win()) {
if (cp == true) {
setTips();
}
return true;
goto out;
}
}
// 如果双方还有子
@ -778,15 +772,11 @@ bool NineChess::place(int pos, long time_p, bool cp)
context.action = ACTION_CAPTURE;
}
if (cp == true) {
setTips();
goto out;
}
return true;
}
// 对于中局落子 (ontext.stage == GAME_MOVING)
// 对于中局落子
else if (context.stage == GAME_MOVING) {
// 如果落子不合法
if ((context.turn == PLAYER1 &&
(context.nPiecesOnBoard_1 > currentRule.nPiecesAtLeast || !currentRule.allowFlyWhenRemainThreePieces)) ||
@ -800,9 +790,10 @@ bool NineChess::place(int pos, long time_p, bool cp)
}
// 不在着法表中
if (i == 4)
if (i == 4) {
return false;
}
}
// 移子
move_ = (currentPos << 8) + pos;
@ -814,14 +805,19 @@ bool NineChess::place(int pos, long time_p, bool cp)
currentStep++;
moveStep++;
}
board_[pos] = board_[currentPos];
#if ((defined HASH_MAP_ENABLE) || (defined BOOK_LEARNING) || (defined THREEFOLD_REPETITION))
updateHash(pos);
#endif
board_[currentPos] = '\x00';
#if ((defined HASH_MAP_ENABLE) || (defined BOOK_LEARNING) || (defined THREEFOLD_REPETITION))
revertHash(currentPos);
#endif
currentPos = pos;
n = addMills(currentPos);
@ -835,10 +831,7 @@ bool NineChess::place(int pos, long time_p, bool cp)
// 如果决出胜负
if (win()) {
if (cp == true) {
setTips();
}
return true;
goto out;
}
}
// 中局阶段成三
@ -848,19 +841,14 @@ bool NineChess::place(int pos, long time_p, bool cp)
// 进入去子状态
context.action = ACTION_CAPTURE;
if (cp == true) {
setTips();
}
}
out:
if (cp == true) {
setTips();
}
return true;
}
return false;
}
bool NineChess::place(int c, int p, long time_p)