Skip to content

Commit

Permalink
Small simplifications (#300)
Browse files Browse the repository at this point in the history
Also makes certain behaviours explicit

Bench: 7592451
  • Loading branch information
cj5716 authored Jan 9, 2024
1 parent 5defab4 commit fa48fed
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 14 deletions.
21 changes: 9 additions & 12 deletions src/nnue.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -90,26 +90,23 @@ void NNUE::update(NNUE::accumulator& board_accumulator, std::vector<std::pair<st
int subs = NNUESub.size();
// Quiets
if (adds == 1 && subs == 1) {
auto [whiteAddIdx, blackAddIdx] = NNUEAdd.back();
auto [whiteSubIdx, blackSubIdx] = NNUESub.back();
auto [whiteAddIdx, blackAddIdx] = NNUEAdd[0];
auto [whiteSubIdx, blackSubIdx] = NNUESub[0];
addSub(board_accumulator, whiteAddIdx, blackAddIdx, whiteSubIdx, blackSubIdx);
}
// Captures
else if (adds == 1 && subs == 2) {
auto [whiteAddIdx, blackAddIdx] = NNUEAdd.back();
auto [whiteSubIdx1, blackSubIdx1] = NNUESub.back();
NNUESub.pop_back();
auto [whiteSubIdx2, blackSubIdx2] = NNUESub.back();
auto [whiteAddIdx, blackAddIdx] = NNUEAdd[0];
auto [whiteSubIdx1, blackSubIdx1] = NNUESub[0];
auto [whiteSubIdx2, blackSubIdx2] = NNUESub[1];
addSubSub(board_accumulator, whiteAddIdx, blackAddIdx, whiteSubIdx1, blackSubIdx1, whiteSubIdx2, blackSubIdx2);
}
// Castling
else {
auto [whiteAddIdx1, blackAddIdx1] = NNUEAdd.back();
NNUEAdd.pop_back();
auto [whiteAddIdx2, blackAddIdx2] = NNUEAdd.back();
auto [whiteSubIdx1, blackSubIdx1] = NNUESub.back();
NNUESub.pop_back();
auto [whiteSubIdx2, blackSubIdx2] = NNUESub.back();
auto [whiteAddIdx1, blackAddIdx1] = NNUEAdd[0];
auto [whiteAddIdx2, blackAddIdx2] = NNUEAdd[1];
auto [whiteSubIdx1, blackSubIdx1] = NNUESub[0];
auto [whiteSubIdx2, blackSubIdx2] = NNUESub[1];
addSub(board_accumulator, whiteAddIdx1, blackAddIdx1, whiteSubIdx1, blackSubIdx1);
addSub(board_accumulator, whiteAddIdx2, blackAddIdx2, whiteSubIdx2, blackSubIdx2);
}
Expand Down
4 changes: 2 additions & 2 deletions src/search.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -636,7 +636,7 @@ int Negamax(int alpha, int beta, int depth, const bool cutNode, S_ThreadData* td
if (doFullSearch)
{
// SF yoink, based on the value returned by our reduced search see if we should search deeper, this is an exact yoink of what SF and frankly i don't care lmao
const bool doDeeperSearch = score > (bestScore + 53 + 2 * newDepth);
const bool doDeeperSearch = depthReduction && score > (bestScore + 53 + 2 * newDepth);
score = -Negamax<false>(-alpha - 1, -alpha, newDepth + doDeeperSearch, !cutNode, td, ss + 1);
if (depthReduction)
{
Expand All @@ -646,7 +646,7 @@ int Negamax(int alpha, int beta, int depth, const bool cutNode, S_ThreadData* td
}
}

// PVS Search: Search the first move and every move that produced a score better than alpha with full depth and a full window
// PVS Search: Search the first move and every move that beat alpha with full depth and a full window
if (pvNode && (movesSearched == 0 || score > alpha))
score = -Negamax<true>(-beta, -alpha, newDepth, false, td, ss + 1);

Expand Down

0 comments on commit fa48fed

Please sign in to comment.