From c31a3f40bd817b8b6b362e67e58b761150112bec Mon Sep 17 00:00:00 2001 From: joeismad <49701033+joeismad@users.noreply.github.com> Date: Tue, 21 May 2019 22:31:52 -0400 Subject: [PATCH 1/2] Update main.go --- main.go | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/main.go b/main.go index 476e246..43a95a0 100644 --- a/main.go +++ b/main.go @@ -607,6 +607,21 @@ func uploadGame(c *gin.Context) { c.String(500, "Saving pgn") return } + // Save resign rate + s := fmt.Sprintf("%f", resign_fp_threshold) + if (s == "-1.000000") { + return + } else { + resign_path := fmt.Sprintf("resign/run%d/%d.txt", training_run.ID, nextGameNumber) + os.MkdirAll(filepath.Dir(resign_path), os.ModePerm) + err = ioutil.WriteFile(resign_path, []byte(s), 0644) + if err != nil { + log.Println(err.Error()) + c.String(500, "Saving resign file") + return + } + } + c.String(http.StatusOK, fmt.Sprintf("File %s uploaded successfully with fields user=%s.", file.Filename, user.Username)) } From 3d69f245414cf907faae5d65c5ce26245c04ff09 Mon Sep 17 00:00:00 2001 From: joeismad <49701033+joeismad@users.noreply.github.com> Date: Tue, 21 May 2019 22:41:56 -0400 Subject: [PATCH 2/2] Add files via upload --- scripts/resign.py | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100644 scripts/resign.py diff --git a/scripts/resign.py b/scripts/resign.py new file mode 100644 index 0000000..4f3ab12 --- /dev/null +++ b/scripts/resign.py @@ -0,0 +1,40 @@ +import os +import time +import glob + +all_resign = [] +d = 0 +xd = 0 +avg = 0 +uploadpath = "/root/lczero-server/resign/run1" +games_per_net = 30000 +resign_playthrough = 15 +false_resign_rate = 5 + + +while True: + upload_path = os.path.join(uploadpath, '*') + resigns = sorted(glob.iglob(upload_path), key=os.path.getmtime, reverse=True) + print(resigns[0]) + for resign in resigns: + if resign.endswith("txt"): + d = d + 1 + s = open(resign, "r") + s1 = s.read() + all_resign.append(s1) + if d > (games_per_net * resign_playthrough * .01): + all_resign.sort() + y = int(len(all_resign) / (100 / false_resign_rate)) + for i in range(y-5, y+4): + xd += 1 + avg += float(all_resign[i]) + avg = round((avg/xd) * 100, 1) + print("games: " + str(d)) + print(str(false_resign_rate) + "% false resigns @ resign rate: " + str(avg) + "%") + break + xd = 0 + avg = 0 + d = 0 + all_resign = [] + time.sleep(60*60*2) +