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

Use text files to rescore #22

Open
wants to merge 9 commits into
base: 8menrescore
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 26 additions & 1 deletion src/selfplay/loop.cc
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
#include <stdio.h>
#include <iostream>
#include <fstream>
#include <unordered_map>

namespace lczero {

Expand Down Expand Up @@ -69,6 +70,7 @@ std::atomic<int> fixed_counts[3];
std::atomic<int> policy_bump(0);
std::atomic<int> policy_nobump_total_hist[11];
std::atomic<int> policy_bump_total_hist[11];
std::unordered_map <std::string, int8_t> fensMap;

void ProcessFile(const std::string& file, SyzygyTablebase* tablebase,
std::string outputDir, float distTemp, float distOffset,
Expand Down Expand Up @@ -117,7 +119,11 @@ void ProcessFile(const std::string& file, SyzygyTablebase* tablebase,
if ((board.ours() | board.theirs()).count() == 8) {
Position pos = history.Last();
std::string target_fen = pos.GetFen();
if (fileContents[i].result == 0) {
auto score = fensMap.find(target_fen);
if (score != fensMap.end()) {
fileContents[i].result = score->second;
}
else if (fileContents[i].result == 0) {
draws << target_fen << std::endl;
} else if (fileContents[i].result == 1) {
wins << target_fen << std::endl;
Expand Down Expand Up @@ -456,6 +462,25 @@ void RescoreLoop::RunLoop() {
for (int i = 0; i < files.size(); i++) {
files[i] = inputDir + "/" + files[i];
}

std::ifstream winsFile("wins.txt");
std::ifstream drawsFile("draws.txt");
std::ifstream lossesFile("losses.txt");
std::string line;

while(std::getline(winsFile, line))
{
fensMap[line] = 1;
}
while(std::getline(drawsFile, line))
{
fensMap[line] = 0;
}
while(std::getline(lossesFile, line))
{
fensMap[line] = -1;
}

float dtz_boost =
options_.GetOptionsDict().Get<float>(kMinDTZBoostId.GetId());
int threads = options_.GetOptionsDict().Get<int>(kThreadsId.GetId());
Expand Down