Skip to content

Commit

Permalink
another metric
Browse files Browse the repository at this point in the history
  • Loading branch information
Sander Land committed Apr 19, 2021
1 parent c2ca285 commit 3adde54
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 15 deletions.
10 changes: 10 additions & 0 deletions katrain/core/game_node.py
Original file line number Diff line number Diff line change
Expand Up @@ -348,6 +348,16 @@ def comment(self, sgf=False, teach=False, details=False, interactive=True):
if previous_top_move.get("pv") and (sgf or details):
pv = self.make_pv(single_move.player, previous_top_move["pv"], interactive)
text += i18n._("Info:PV").format(pv=pv) + "\n"
# testing
cands = self.parent.candidate_moves
filtered_cands = [d for d in cands if d["order"] < ADDITIONAL_MOVE_ORDER and "prior" in d]
cands_policy = sum(d["prior"] for d in filtered_cands)
good_move_policy = sum(d["prior"] for d in filtered_cands if d["pointsLost"] < 0.5)
# how many bad candidates were considered
weight = max(cands_policy - good_move_policy, 1e-6)
weight2 = sum([max(d["pointsLost"], 0) * d["prior"] for d in filtered_cands])
text += f"Last Move Difficulty A: {weight}\n"
text += f"Last Move Difficulty B: {weight2}\n"

if sgf or details or teach:
currmove_pol_rank, currmove_pol_prob, policy_ranking = self.move_policy_stats()
Expand Down
35 changes: 20 additions & 15 deletions katrain/gui/popups.py
Original file line number Diff line number Diff line change
Expand Up @@ -365,7 +365,9 @@ def build_and_set_properties(self, *_args):
for k in ["dot color", "point loss threshold", "num undos", "show dots", "save dots"]:
self.options_grid.add_widget(DescriptionLabel(text=i18n._(k), font_name=i18n.font_name, font_size=dp(17)))

for i, color, threshold, undo, show_dot, savesgf in list(zip(range(len(thresholds)),Theme.EVAL_COLORS[theme], thresholds, undos, show_dots, savesgfs))[::-1]:
for i, color, threshold, undo, show_dot, savesgf in list(
zip(range(len(thresholds)), Theme.EVAL_COLORS[theme], thresholds, undos, show_dots, savesgfs)
)[::-1]:
self.add_option_widgets(
[
BackgroundMixin(background_color=color, size_hint=[0.9, 0.9]),
Expand Down Expand Up @@ -465,20 +467,20 @@ class BaseConfigPopup(QuickConfigGui):

KATAGOS = {
"win": {
"OpenCL v1.8.1": "https://github.com/lightvector/KataGo/releases/download/v1.8.1/katago-v1.8.1-opencl-windows-x64.zip",
"Eigen AVX2 (Modern CPUs) v1.8.1": "https://github.com/lightvector/KataGo/releases/download/v1.8.1/katago-v1.8.1-eigenavx2-windows-x64.zip",
"Eigen (CPU, Non-optimized) v1.8.1": "https://github.com/lightvector/KataGo/releases/download/v1.8.1/katago-v1.8.1-eigen-windows-x64.zip",
"OpenCL v1.8.2": "https://github.com/lightvector/KataGo/releases/download/v1.8.2/katago-v1.8.2-opencl-windows-x64.zip",
"Eigen AVX2 (Modern CPUs) v1.8.2": "https://github.com/lightvector/KataGo/releases/download/v1.8.2/katago-v1.8.2-eigenavx2-windows-x64.zip",
"Eigen (CPU, Non-optimized) v1.8.2": "https://github.com/lightvector/KataGo/releases/download/v1.8.2/katago-v1.8.2-eigen-windows-x64.zip",
"OpenCL v1.6.1 (bigger boards)": "https://github.com/lightvector/KataGo/releases/download/v1.6.1%2Bbs29/katago-v1.6.1+bs29-gpu-opencl-windows-x64.zip",
},
"linux": {
"OpenCL v1.8.1": "https://github.com/lightvector/KataGo/releases/download/v1.8.1/katago-v1.8.1-opencl-linux-x64.zip",
"Eigen AVX2 (Modern CPUs) v1.8.1": "https://github.com/lightvector/KataGo/releases/download/v1.8.1/katago-v1.8.1-eigenavx2-linux-x64.zip",
"Eigen (CPU, Non-optimized) v1.8.1": "https://github.com/lightvector/KataGo/releases/download/v1.8.1/katago-v1.8.1-eigen-linux-x64.zip",
"OpenCL v1.8.2": "https://github.com/lightvector/KataGo/releases/download/v1.8.2/katago-v1.8.2-opencl-linux-x64.zip",
"Eigen AVX2 (Modern CPUs) v1.8.2": "https://github.com/lightvector/KataGo/releases/download/v1.8.2/katago-v1.8.2-eigenavx2-linux-x64.zip",
"Eigen (CPU, Non-optimized) v1.8.2": "https://github.com/lightvector/KataGo/releases/download/v1.8.2/katago-v1.8.2-eigen-linux-x64.zip",
"OpenCL v1.6.1 (bigger boards)": "https://github.com/lightvector/KataGo/releases/download/v1.6.1%2Bbs29/katago-v1.6.1+bs29-gpu-opencl-linux-x64.zip",
},
"just-descriptions": {
"CUDA v1.8.1 (Windows)": "https://github.com/lightvector/KataGo/releases/download/v1.8.1/katago-v1.8.1-gpu-cuda10.2-windows-x64.zip",
"CUDA v1.8.1 (Linux)": "https://github.com/lightvector/KataGo/releases/download/v1.8.1/katago-v1.8.1-gpu-cuda10.2-linux-x64.zip",
"CUDA v1.8.2 (Windows)": "https://github.com/lightvector/KataGo/releases/download/v1.8.2/katago-v1.8.2-gpu-cuda10.2-windows-x64.zip",
"CUDA v1.8.2 (Linux)": "https://github.com/lightvector/KataGo/releases/download/v1.8.2/katago-v1.8.2-gpu-cuda10.2-linux-x64.zip",
},
}

Expand Down Expand Up @@ -872,14 +874,17 @@ def _refresh(self, _dt=0):
cands_policy = sum(d["prior"] for d in filtered_cands)
good_move_policy = sum(d["prior"] for d in filtered_cands if d["pointsLost"] < 0.5)
# how many bad candidates were considered
weight = max(cands_policy - good_move_policy, 1e-6)
if points_lost > 0.5:
adj_weight = 0.25 # quite severe
else:
adj_weight = min(0.25, weight)
# weight = max(cands_policy - good_move_policy, 1e-6)
# if points_lost > 0.5:
# adj_weight = 0.25 # quite severe
# else:
# adj_weight = min(0.25, weight)

weight = min(1.0, sum([max(d["pointsLost"], 0) * d["prior"] for d in filtered_cands])) # complexity capped at 1
# adj_weight between 0.05 - 1, dependent on difficulty and points lost
adj_weight = max(0.05, min(1.0, max(weight, points_lost / 4)))

weights[n.player].append((weight, adj_weight))
print(n.player, n.move.gtp(), "w", weight, adj_weight, "ptloss", points_lost)

if n.parent.analysis_complete:
ai_top_move_count[n.player] += int(cands[0]["move"] == n.move.gtp())
Expand Down
4 changes: 4 additions & 0 deletions katrain/popups.kv
Original file line number Diff line number Diff line change
Expand Up @@ -872,23 +872,27 @@
padding: CP_PADDING
SizedRectangleToggleButton:
text: 'Entire Game'
allow_no_selection: False
size_hint: 1,1
group: 'stats_depth'
state: 'down'
on_press: root.set_depth_filter(None)
SizedRectangleToggleButton:
text: 'Opening'
allow_no_selection: False
size_hint: 1,1
group: 'stats_depth'
on_press: root.set_depth_filter((0,50))
SizedRectangleToggleButton:
text: 'Midgame'
allow_no_selection: False
size_hint: 1,1
group: 'stats_depth'
on_press: root.set_depth_filter((51,151))
SizedRectangleToggleButton:
text: 'Endgame'
group: 'stats_depth'
allow_no_selection: False
size_hint: 1,1
on_press: root.set_depth_filter((151,1e9))
BoxLayout:
Expand Down

0 comments on commit 3adde54

Please sign in to comment.