1
0
Fork 0
mirror of https://github.com/sockspls/badfish synced 2025-05-01 01:03:09 +00:00

NNUE: Fix debug build

No functional change
This commit is contained in:
Dariusz Orzechowski 2020-07-25 16:55:14 +02:00 committed by Joost VandeVondele
parent faf08671ff
commit beb956f823
2 changed files with 18 additions and 16 deletions

View file

@ -828,8 +828,6 @@ void Position::do_move(Move m, StateInfo& newSt, bool givesCheck) {
// Move the piece. The tricky Chess960 castling is handled earlier
if (type_of(m) != CASTLING) {
move_piece(from, to);
if (use_nnue())
{
dp0 = piece_id_on(from);
@ -838,6 +836,7 @@ void Position::do_move(Move m, StateInfo& newSt, bool givesCheck) {
evalList.put_piece(dp0, to, pc);
dp.new_piece[0] = evalList.piece_with_id(dp0);
}
move_piece(from, to);
}
// If the moving piece is a pawn do some special extra work
@ -986,8 +985,8 @@ void Position::undo_move(Move m) {
if (use_nnue())
{
PieceId dp1 = st->dirtyPiece.pieceId[1];
assert(evalList.piece_with_id(dp1).fw == PS_NONE);
assert(evalList.piece_with_id(dp1).fb == PS_NONE);
assert(evalList.piece_with_id(dp1).from[WHITE] == PS_NONE);
assert(evalList.piece_with_id(dp1).from[BLACK] == PS_NONE);
evalList.put_piece(dp1, capsq, st->capturedPiece);
}
}
@ -1011,13 +1010,6 @@ void Position::do_castling(Color us, Square from, Square& to, Square& rfrom, Squ
rto = relative_square(us, kingSide ? SQ_F1 : SQ_D1);
to = relative_square(us, kingSide ? SQ_G1 : SQ_C1);
// Remove both pieces first since squares could overlap in Chess960
remove_piece(Do ? from : to);
remove_piece(Do ? rfrom : rto);
board[Do ? from : to] = board[Do ? rfrom : rto] = NO_PIECE; // Since remove_piece doesn't do this for us
put_piece(make_piece(us, KING), Do ? to : from);
put_piece(make_piece(us, ROOK), Do ? rto : rfrom);
if (use_nnue())
{
PieceId dp0, dp1;
@ -1043,6 +1035,13 @@ void Position::do_castling(Color us, Square from, Square& to, Square& rfrom, Squ
evalList.put_piece(dp1, rfrom, make_piece(us, ROOK));
}
}
// Remove both pieces first since squares could overlap in Chess960
remove_piece(Do ? from : to);
remove_piece(Do ? rfrom : rto);
board[Do ? from : to] = board[Do ? rfrom : rto] = NO_PIECE; // Since remove_piece doesn't do this for us
put_piece(make_piece(us, KING), Do ? to : from);
put_piece(make_piece(us, ROOK), Do ? rto : rfrom);
}

View file

@ -302,14 +302,12 @@ struct ExtPieceSquare
// Array for finding the PieceSquare corresponding to the piece on the board
extern ExtPieceSquare kpp_board_index[PIECE_NB];
constexpr bool is_ok(PieceId pid);
constexpr Square rotate180(Square sq);
// Structure holding which tracked piece (PieceId) is where (PieceSquare)
class EvalList
{
// Return relative square when turning the board 180 degrees
constexpr Square rotate180(Square sq) {
return (Square)(sq ^ 63);
}
public:
// Max. number of pieces without kings is 30 but must be a multiple of 4 in AVX2
static const int MAX_LENGTH = 32;
@ -544,6 +542,11 @@ constexpr Square to_sq(Move m) {
return Square(m & 0x3F);
}
// Return relative square when turning the board 180 degrees
constexpr Square rotate180(Square sq) {
return (Square)(sq ^ 0x3F);
}
constexpr int from_to(Move m) {
return m & 0xFFF;
}