GetPromoPiece helper function | bench 1181803
This commit is contained in:
1 parent
7db4fcf59c
commit
68d7dcbccb
3 files changed
+17
-23
No files matched your search
+4
-9
@@ -24,7 +24,7 @@ void Board::Reset() {
|
||||
|
||||
mailbox = std::array<int, 64>();
|
||||
mailbox.fill(nullPieceType);
|
||||
|
||||
|
||||
pinned = std::array<Bitboard, 2>();
|
||||
|
||||
pieces = std::array<Bitboard, 6>();
|
||||
@@ -424,11 +424,10 @@ void Board::MakeMove(Move move) {
|
||||
RemovePiece(attackerPiece, move.MoveFrom(), attackerColor);
|
||||
|
||||
if (move.IsPromo()) {
|
||||
endPiece = move.GetPromoPiece();
|
||||
if (move.IsCapture()) {
|
||||
endPiece = move.GetFlags() - 9;
|
||||
Promote(move.MoveTo(), endPiece, sideToMove, true);
|
||||
} else {
|
||||
endPiece = move.GetFlags() - 5;
|
||||
Promote(move.MoveTo(), endPiece, sideToMove, false);
|
||||
}
|
||||
}
|
||||
@@ -708,7 +707,7 @@ Bitboard Board::CalcPinned(bool color) {
|
||||
int kingSquare = (pieces[King] & colors[color]).getLS1BIndex();
|
||||
|
||||
assert(kingSquare != -1);
|
||||
|
||||
|
||||
Bitboard oppQueens = pieces[Queen] & colors[!color];
|
||||
|
||||
Bitboard potentialAttackers = MOVEGEN::getBishopAttack(kingSquare, colors[!color]) & (oppQueens | (pieces[Bishop] & colors[!color]))
|
||||
@@ -977,11 +976,7 @@ bool Board::GivesDirectCheck(Move &move) {
|
||||
int attackerType = nullPieceType;
|
||||
|
||||
if (move.IsPromo()) {
|
||||
if (move.IsCapture()) {
|
||||
attackerType = move.GetFlags() - 9;
|
||||
} else {
|
||||
attackerType = move.GetFlags() - 5;
|
||||
}
|
||||
attackerType = move.GetPromoPiece();
|
||||
} else {
|
||||
attackerType = GetPieceType(move.MoveFrom());
|
||||
}
|
||||
|
||||
+11
-3
@@ -65,7 +65,7 @@ public:
|
||||
}
|
||||
|
||||
bool IsCastle() {
|
||||
return (GetFlags() == kingCastle || GetFlags() == queenCastle);
|
||||
return (GetFlags() == kingCastle || GetFlags() == queenCastle);
|
||||
}
|
||||
|
||||
void PrintMove() {
|
||||
@@ -84,7 +84,7 @@ public:
|
||||
}
|
||||
}
|
||||
|
||||
std::string GetMoveString() {
|
||||
std::string GetMoveString() {
|
||||
std::string result = squareCoords[MoveFrom()];
|
||||
result += squareCoords[MoveTo()];
|
||||
|
||||
@@ -106,7 +106,7 @@ public:
|
||||
uint16_t ConvertToViriMoveFormat() {
|
||||
uint16_t viriMove = 0;
|
||||
int flags = GetFlags();
|
||||
|
||||
|
||||
viriMove = MoveFrom();
|
||||
|
||||
if (flags == kingCastle || flags == queenCastle) {
|
||||
@@ -150,6 +150,14 @@ public:
|
||||
return viriMove;
|
||||
}
|
||||
|
||||
int GetPromoPiece() {
|
||||
if (IsCapture()) {
|
||||
return GetFlags() - 9;
|
||||
} else {
|
||||
return GetFlags() - 5;
|
||||
}
|
||||
}
|
||||
|
||||
operator uint16_t() {
|
||||
return m_move;
|
||||
}
|
||||
|
||||
+2
-11
@@ -174,11 +174,7 @@ bool SEE(Board& board, Move& move, int threshold) {
|
||||
|
||||
// Next victim is moved piece or promo piece
|
||||
if (move.IsPromo()) {
|
||||
if (move.IsCapture()) {
|
||||
nextVictim = move.GetFlags() - 9;
|
||||
} else {
|
||||
nextVictim = move.GetFlags() - 5;
|
||||
}
|
||||
nextVictim = move.GetPromoPiece();
|
||||
}
|
||||
|
||||
int balance = MoveEstimatedValue(board, move) - threshold;
|
||||
@@ -956,12 +952,7 @@ int MoveEstimatedValue(Board& board, Move& move) {
|
||||
int value = pieceType != nullPieceType ? SEEPieceValues[pieceType] : 0;
|
||||
|
||||
if (move.IsPromo()) {
|
||||
int promoPiece = -1;
|
||||
if (move.IsCapture()) {
|
||||
promoPiece = move.GetFlags() - 9;
|
||||
} else {
|
||||
promoPiece = move.GetFlags() - 5;
|
||||
}
|
||||
int promoPiece = move.GetPromoPiece();
|
||||
|
||||
value += SEEPieceValues[promoPiece] - SEEPieceValues[Pawn];
|
||||
} else if (move.GetFlags() == epCapture) {
|
||||
|
||||
Reference in new issue
Block a user