From be8139f6c7e28802c35d47d121ff7188f8cfb930 Mon Sep 17 00:00:00 2001 From: CalciteM Team Date: Fri, 13 Sep 2019 14:11:25 +0800 Subject: [PATCH] =?UTF-8?q?refactor:=20context.board.locations=20=E6=94=B9?= =?UTF-8?q?=E4=B8=BA=20boardLocations?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/game/position.cpp | 16 ++++++++-------- src/game/position.h | 2 +- src/game/positon.h | 2 +- 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/src/game/position.cpp b/src/game/position.cpp index 1b296c2d..ade6c860 100644 --- a/src/game/position.cpp +++ b/src/game/position.cpp @@ -26,7 +26,7 @@ Position::Position() { - // 单独提出 boardLocations 等数据,免得每次都写 context.board.locations; + // 单独提出 boardLocations 等数据,免得每次都写 boardLocations; boardLocations = context.board.locations; // 创建哈希数据 @@ -62,7 +62,7 @@ Position &Position::operator= (const Position &position) moveStep = position.moveStep; randomMove_ = position.randomMove_; giveUpIfMostLose_ = position.giveUpIfMostLose_; - boardLocations = context.board.locations; + boardLocations = boardLocations; currentLocation = position.currentLocation; winner = position.winner; startTime = position.startTime; @@ -170,10 +170,10 @@ bool Position::setContext(const struct Rule *rule, step_t maxStepsLedToDraw, int // 当前棋局(3×8) if (locations == nullptr) { - memset(context.board.locations, 0, sizeof(context.board.locations)); + memset(boardLocations, 0, sizeof(boardLocations)); context.hash = 0; } else { - memcpy(context.board.locations, locations, sizeof(context.board.locations)); + memcpy(boardLocations, locations, sizeof(boardLocations)); } // 计算盘面子数 @@ -191,11 +191,11 @@ bool Position::setContext(const struct Rule *rule, step_t maxStepsLedToDraw, int for (int r = 1; r < Board::N_RINGS + 2; r++) { for (int s = 0; s < Board::N_SEATS; s++) { int location = r * Board::N_SEATS + s; - if (context.board.locations[location] & 0x10) { + if (boardLocations[location] & 0x10) { context.nPiecesOnBoard_1++; - } else if (context.board.locations[location] & 0x20) { + } else if (boardLocations[location] & 0x20) { context.nPiecesOnBoard_2++; - } else if (context.board.locations[location] & 0x0F) { + } else if (boardLocations[location] & 0x0F) { // 不计算盘面子数 } } @@ -1045,7 +1045,7 @@ bool Position::win(bool forceDraw) // 计算玩家1和玩家2的棋子活动能力之差 int Position::getMobilityDiff(enum player_t turn, const Rule &rule, int nPiecesOnBoard_1, int nPiecesOnBoard_2, bool includeFobidden) { - int *locations = context.board.locations; + int *locations = boardLocations; int mobility1 = 0; int mobility2 = 0; int diff = 0; diff --git a/src/game/position.h b/src/game/position.h index 586200d7..f40e1493 100644 --- a/src/game/position.h +++ b/src/game/position.h @@ -148,7 +148,7 @@ public: // 获取棋盘数据 const int *getBoardLocations() const { - return context.board.locations; + return boardLocations; } // 获取当前棋子位置点 diff --git a/src/game/positon.h b/src/game/positon.h index d636ccc1..824a073a 100644 --- a/src/game/positon.h +++ b/src/game/positon.h @@ -148,7 +148,7 @@ public: // 获取棋盘数据 const int *getBoardLocations() const { - return context.board.locations; + return boardLocations; } // 获取当前棋子位置点