Skip to content

Commit

Permalink
Merge branch 'master' into keepstealing
Browse files Browse the repository at this point in the history
  • Loading branch information
PGG106 authored Dec 24, 2024
2 parents 620b959 + b1983e4 commit 749f1e0
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion src/nnue.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,18 @@ void NNUE::Pov_Accumulator::refresh(Position *pos) {
// figure out a diff
for (int piece = WP; piece <= BK; piece++) {
auto added = pos->bitboards[piece] & ~cachedEntry->occupancies[piece];
auto removed = cachedEntry->occupancies[piece] & ~pos->bitboards[piece];
while (added && removed) {
auto added_square = popLsb(added);
auto added_index = GetIndex(piece, added_square, kingSq, flip);
const auto Add = &net.FTWeights[added_index * L1_SIZE];
auto removed_square = popLsb(removed);
auto removed_index = GetIndex(piece, removed_square, kingSq, flip);
const auto Sub = &net.FTWeights[removed_index * L1_SIZE];
for (int i = 0; i < L1_SIZE; i++) {
this->values[i] = this->values[i] + Add[i] - Sub[i];
}
}
while (added) {
auto square = popLsb(added);
auto index = GetIndex(piece, square, kingSq, flip);
Expand All @@ -146,7 +158,6 @@ void NNUE::Pov_Accumulator::refresh(Position *pos) {
this->values[i] += Add[i];
}
}
auto removed = cachedEntry->occupancies[piece] & ~pos->bitboards[piece];
while (removed) {
auto square = popLsb(removed);
auto index = GetIndex(piece, square, kingSq, flip);
Expand Down

0 comments on commit 749f1e0

Please sign in to comment.