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