Refactor #178

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

No files matched your search

+4 -9
View File
@@ -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
View File
@@ -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
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) {