Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add history to the NNCache key #546

Merged
merged 9 commits into from
May 7, 2018
7 changes: 7 additions & 0 deletions src/Network.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1028,6 +1028,13 @@ void Network::softmax(const std::vector<float>& input,
Network::Netresult Network::get_scored_moves(const BoardHistory& pos, DebugRawData* debug_data, bool skip_cache) {
Netresult result;
auto full_key = pos.cur().full_key();
// Mix in the history to try and ensure no false positive lookups where
// the cached values would differ from the NN evals.
int history_count = pos.positions.size();
for (int i = history_count - 2; i >= std::max(0, history_count - T_HISTORY); i--) {
full_key *= 31;
full_key ^= pos.positions[i].full_key();
}

// See if we already have this in the cache.
if (!skip_cache) {
Expand Down