refactor: playerId 和 player 替换完毕

This commit is contained in:
Calcitem 2020-07-05 21:21:15 +08:00
parent 9568a01aae
commit 19189dbfe1
8 changed files with 23 additions and 23 deletions

View File

@ -103,7 +103,7 @@ void MovePicker::score()
// for 12 men, white 's 2nd move place star point is as important as close mill (TODO)
#ifdef ALPHABETA_AI
if (rule.nTotalPiecesEachSide == 12 &&
position->getPiecesOnBoardCount(2) < 2 && // patch: only when white's 2nd move
position->getPiecesOnBoardCount(WHITE) < 2 && // patch: only when white's 2nd move
Board::isStar(static_cast<Square>(m))) {
cur->rating += RATING_STAR_SQUARE;
}

View File

@ -357,7 +357,7 @@ Value AIAlgorithm::search(Depth depth, Value alpha, Value beta)
#if 0
// TODO: 有必要针对深度微调 value?
if (position->turn == PLAYER_BLACK)
if (position->turn == BLACK)
bestValue += tte.depth - depth;
else
bestValue -= tte.depth - depth;

View File

@ -37,7 +37,7 @@ AiThread::AiThread(int color, QObject *parent) :
depth(2),
timeLimit(3600)
{
this->playerId = color;
this->us = color;
connect(this, &AiThread::searchStarted, this, [=]() {timer.start(timeLimit * 1000 - 118 /* 118ms is return time */); }, Qt::QueuedConnection);
connect(this, &AiThread::searchFinished, this, [=]() {timer.stop(); }, Qt::QueuedConnection);
@ -210,7 +210,7 @@ void AiThread::run()
Color sideToMove = NOCOLOR;
loggerDebug("Thread %d start\n", playerId);
loggerDebug("Thread %d start\n", us);
ai.bestvalue = ai.lastvalue = VALUE_ZERO;
@ -219,7 +219,7 @@ void AiThread::run()
sideToMove = position->sideToMove;
if (sideToMove != playerId) {
if (sideToMove != us) {
pauseCondition.wait(&mutex);
mutex.unlock();
continue;
@ -274,7 +274,7 @@ void AiThread::run()
mutex.unlock();
}
loggerDebug("Thread %d quit\n", playerId);
loggerDebug("Thread %d quit\n", us);
}
void AiThread::act()

View File

@ -82,7 +82,7 @@ public slots:
void emitCommand();
public:
int playerId;
int us;
private:
const char* strCommand {};

View File

@ -336,7 +336,7 @@ int Board::getSurroundedEmptyLocationCount(Color sideToMove, int nPiecesOnBoard[
return count;
}
void Board::getSurroundedPieceCount(Square square, Color sideToMove, int &nPlayerPiece, int &nTheirPieces, int &nBanned, int &nEmpty)
void Board::getSurroundedPieceCount(Square square, Color sideToMove, int &nOurPieces, int &nTheirPieces, int &nBanned, int &nEmpty)
{
Square moveSquare;
@ -358,7 +358,7 @@ void Board::getSurroundedPieceCount(Square square, Color sideToMove, int &nPlaye
break;
default:
if (sideToMove == pieceType >> PLAYER_SHIFT) {
nPlayerPiece++;
nOurPieces++;
} else {
nTheirPieces++;
}

View File

@ -58,7 +58,7 @@ public:
bool isAllInMills(Color c);
int getSurroundedEmptyLocationCount(Color sideToMove, int nPiecesOnBoard[], Square square, bool includeFobidden);
void getSurroundedPieceCount(Square square, Color sideToMove, int &nPlayerPiece, int &nTheirPieces, int &nBanned, int &nEmpty);
void getSurroundedPieceCount(Square square, Color sideToMove, int &nOurPieces, int &nTheirPieces, int &nBanned, int &nEmpty);
bool isAllSurrounded(Color sideToMove, int nPiecesOnBoard[]);
int addMills(Square square);

View File

@ -207,7 +207,7 @@ bool Position::placePiece(Square square, bool updateCmdlist)
int piece = '\x00';
int n = 0;
int playerId = sideToMove;
int us = sideToMove;
Bitboard fromTo;
@ -226,16 +226,16 @@ bool Position::placePiece(Square square, bool updateCmdlist)
Board::squareToPolar(square, file, rank);
if (phase == PHASE_PLACING) {
piece = (0x01 | (sideToMove << PLAYER_SHIFT)) + rule.nTotalPiecesEachSide - nPiecesInHand[playerId];
nPiecesInHand[playerId]--;
nPiecesOnBoard[playerId]++;
piece = (0x01 | (sideToMove << PLAYER_SHIFT)) + rule.nTotalPiecesEachSide - nPiecesInHand[us];
nPiecesInHand[us]--;
nPiecesOnBoard[us]++;
board.locations[square] = piece;
updateKey(square);
board.byTypeBB[ALL_PIECES] |= square;
board.byTypeBB[playerId] |= square;
board.byTypeBB[us] |= square;
move = static_cast<Move>(square);
@ -316,7 +316,7 @@ bool Position::placePiece(Square square, bool updateCmdlist)
fromTo = square_bb(currentSquare) | square_bb(square);
board.byTypeBB[ALL_PIECES] ^= fromTo;
board.byTypeBB[playerId] ^= fromTo;
board.byTypeBB[us] ^= fromTo;
board.locations[square] = board.locations[currentSquare];
@ -894,9 +894,9 @@ void Position::setTips()
}
}
time_t Position::getElapsedTime(int playerId)
time_t Position::getElapsedTime(int us)
{
return elapsedSeconds[playerId];
return elapsedSeconds[us];
}
void Position::constructKey()

View File

@ -90,7 +90,7 @@ public:
return action;
}
time_t getElapsedTime(int playerId);
time_t getElapsedTime(int us);
const string getTips() const
{
@ -117,14 +117,14 @@ public:
startTime = stimeb;
}
int getPiecesInHandCount(int playerId) const
int getPiecesInHandCount(Color c) const
{
return nPiecesInHand[playerId];
return nPiecesInHand[c];
}
int getPiecesOnBoardCount(int playerId) const
int getPiecesOnBoardCount(Color c) const
{
return nPiecesOnBoard[playerId];
return nPiecesOnBoard[c];
}
int getNum_NeedRemove() const