refactor: Rename PHASE_NOTSTARTED to PHASE_READY

This commit is contained in:
Calcitem 2019-09-28 11:08:24 +08:00
parent a02cdd9778
commit 9612c014cd
5 changed files with 13 additions and 13 deletions

View File

@ -37,7 +37,7 @@ value_t Evaluation::getValue(Game &tempGame, Position *position, AIAlgorithm::No
#endif
switch (position->phase) {
case PHASE_NOTSTARTED:
case PHASE_READY:
break;
case PHASE_PLACING:

View File

@ -50,7 +50,7 @@ void MoveList::generate(AIAlgorithm &ai, Game &tempGame,
newCapacity = 6;
}
break;
case PHASE_NOTSTARTED:
case PHASE_READY:
newCapacity = 24;
break;
default:
@ -74,7 +74,7 @@ void MoveList::generate(AIAlgorithm &ai, Game &tempGame,
case ACTION_CHOOSE:
case ACTION_PLACE:
// 对于摆子阶段
if (tempGame.position.phase & (PHASE_PLACING | PHASE_NOTSTARTED)) {
if (tempGame.position.phase & (PHASE_PLACING | PHASE_READY)) {
for (move_t i : movePriorityTable) {
location = i;
@ -82,7 +82,7 @@ void MoveList::generate(AIAlgorithm &ai, Game &tempGame,
continue;
}
if (tempGame.position.phase != PHASE_NOTSTARTED || node != root) {
if (tempGame.position.phase != PHASE_READY || node != root) {
ai.addNode(node, VALUE_ZERO, (move_t)location, bestMove, tempGame.position.sideToMove);
} else {
// 若为先手,则抢占星位

View File

@ -173,7 +173,7 @@ bool Game::setPosition(const struct Rule *newRule)
bool Game::reset()
{
if (position.phase == PHASE_NOTSTARTED &&
if (position.phase == PHASE_READY &&
elapsedSeconds[1] == elapsedSeconds[2] == 0) {
return true;
}
@ -183,7 +183,7 @@ bool Game::reset()
moveStep = 0;
// 局面阶段标识
position.phase = PHASE_NOTSTARTED;
position.phase = PHASE_READY;
// 设置轮流状态
setSideToMove(PLAYER_1);
@ -262,7 +262,7 @@ bool Game::start()
reset();
[[fallthrough]];
// 如果游戏处于未开始状态
case PHASE_NOTSTARTED:
case PHASE_READY:
// 启动计时器
startTime = time(NULL);
// 进入开局状态
@ -280,7 +280,7 @@ bool Game::place(int location, int8_t updateCmdlist)
return false;
// 如果局面为“未开局”,则开局
if (position.phase == PHASE_NOTSTARTED)
if (position.phase == PHASE_READY)
start();
// 如非“落子”状态返回false
@ -961,7 +961,7 @@ void Game::setTips()
string turnStr = Player::chToStr(position.chSide);
switch (position.phase) {
case PHASE_NOTSTARTED:
case PHASE_READY:
tips = "轮到玩家1落子剩余" + std::to_string(position.nPiecesInHand[1]) + "" +
" 比分 " + to_string(score[1]) + ":" + to_string(score[2]) + ", 和棋 " + to_string(score_draw);
break;

View File

@ -95,12 +95,12 @@ enum player_t : uint8_t
enum phase_t : uint16_t
{
PHASE_NONE = 0,
PHASE_NOTSTARTED = 1, // 未开局
PHASE_READY = 1, // 未开局
PHASE_PLACING = 1 << 1, // 开局(摆棋)
PHASE_MOVING = 1 << 2, // 中局(走棋)
PHASE_GAMEOVER = 1 << 3, // 结局
PHASE_PLAYING = PHASE_PLACING | PHASE_MOVING, // 进行中
PHASE_NOTPLAYING = PHASE_NOTSTARTED | PHASE_GAMEOVER, // 不在进行中
PHASE_NOTPLAYING = PHASE_READY | PHASE_GAMEOVER, // 不在进行中
};
enum value_t : int16_t

View File

@ -669,7 +669,7 @@ bool GameController::actionPiece(QPointF pos)
}
// 如果未开局则开局
if (game.getPhase() == PHASE_NOTSTARTED)
if (game.getPhase() == PHASE_READY)
gameStart();
// 判断执行选子、落子或去子
@ -838,7 +838,7 @@ bool GameController::command(const QString &cmd, bool update /* = true */)
}
// 如果未开局则开局
if (game.getPhase() == PHASE_NOTSTARTED) {
if (game.getPhase() == PHASE_READY) {
gameStart();
}