Refactor #178

Merged
rektdie merged 3 commits from refactor into main 2026-04-05 03:07:21 +02:00
3 changed files with 12 additions and 18 deletions
Showing only changes of commit 68d7dcbccb - Show all commits

No files matched your search

+2 -7
View File
@@ -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);
}
}
@@ -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());
}
+8
View File
@@ -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
View File
@@ -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) {