board: 新增 locationToPlayer() 函数
This commit is contained in:
parent
907534d0c8
commit
3f299c8f2b
|
@ -195,12 +195,17 @@ square_t Board::polarToSquare(int r, int s)
|
|||
return static_cast<square_t>(r * N_SEATS + s - 1);
|
||||
}
|
||||
|
||||
player_t Board::locationToPlayer(square_t square)
|
||||
{
|
||||
return player_t(locations[square] & 0x30);
|
||||
}
|
||||
|
||||
int Board::inHowManyMills(square_t square, player_t player)
|
||||
{
|
||||
int n = 0;
|
||||
|
||||
if (player == PLAYER_NOBODY) {
|
||||
player = player_t(locations[square] & 0x30);
|
||||
player = locationToPlayer(square);
|
||||
}
|
||||
|
||||
for (int l = 0; l < LINE_TYPES_COUNT; l++) {
|
||||
|
@ -223,7 +228,7 @@ int Board::addMills(square_t square)
|
|||
uint64_t mill = 0;
|
||||
int n = 0;
|
||||
int idx[3], min, temp;
|
||||
char m = locations[square] & 0x30;
|
||||
player_t m = locationToPlayer(square);
|
||||
|
||||
for (int i = 0; i < 3; i++) {
|
||||
idx[0] = square;
|
||||
|
|
|
@ -109,6 +109,8 @@ public:
|
|||
|
||||
static void printBoard();
|
||||
|
||||
player_t locationToPlayer(square_t square);
|
||||
|
||||
//private:
|
||||
|
||||
// 棋局,抽象为一个 5*8 的数组,上下两行留空
|
||||
|
@ -117,8 +119,8 @@ public:
|
|||
0x0F 代表禁点
|
||||
0x11~0x1C 代表先手第 1~12 子
|
||||
0x21~0x2C 代表后手第 1~12 子
|
||||
判断棋子是先手的用 (locations[i] & 0x10)
|
||||
判断棋子是后手的用 (locations[i] & 0x20)
|
||||
判断棋子是先手的用 (locations[square] & 0x10)
|
||||
判断棋子是后手的用 (locations[square] & 0x20)
|
||||
*/
|
||||
location_t locations[SQ_EXPANDED_COUNT]{};
|
||||
|
||||
|
|
|
@ -43,7 +43,7 @@ public:
|
|||
|
||||
inline static int toId(player_t player)
|
||||
{
|
||||
return player == PLAYER_BLACK ? 1 : 2;
|
||||
return player >> PLAYER_SHIFT;
|
||||
}
|
||||
|
||||
inline static player_t idToPlayer(int id)
|
||||
|
|
|
@ -1137,7 +1137,7 @@ hash_t StateInfo::updateHash(square_t square)
|
|||
// PieceType is boardLocations[square]
|
||||
|
||||
// 0b00 表示空白,0b01 = 1 表示先手棋子,0b10 = 2 表示后手棋子,0b11 = 3 表示禁点
|
||||
int pieceType = (boardLocations[square] & 0x30) >> 4;
|
||||
int pieceType = Player::toId(position->board.locationToPlayer(square));
|
||||
|
||||
// 清除或者放置棋子
|
||||
position->hash ^= zobrist[square][pieceType];
|
||||
|
|
Loading…
Reference in New Issue