minor fix

This commit is contained in:
Sander Land committed 2020-06-01 13:22:49 +02:00
1 parent 601db1ca8a
commit 3ba97f73ec
5 files changed
+14 -9

No files matched your search

+1
View File
@@ -347,6 +347,7 @@ class KaTrainGui(Screen, KaTrainBase):
"t": self.analysis_controls.ownership,
"r": self.analysis_controls.policy,
"enter": ("ai-move",),
"numpadenter": ("ai-move",),
"a": ("analyze-extra", "extra"),
"s": ("analyze-extra", "equalize"),
"d": ("analyze-extra", "sweep"),
+9 -5
View File
@@ -15,6 +15,10 @@ from katrain.core.constants import (
AI_JIGO,
AI_SCORELOSS,
AI_DEFAULT,
AI_INFLUENCE,
AI_LOCAL,
AI_TENUKI,
AI_TERRITORY,
)
from katrain.core.engine import EngineDiedException
from katrain.core.game import Game, GameNode, Move
@@ -99,7 +103,7 @@ def ai_move(game: Game, ai_mode: str, ai_settings: Dict) -> Tuple[Move, GameNode
elif ai_mode in AI_STRATEGIES_PICK:
legal_policy_moves = [(pol, mv) for pol, mv in policy_moves if not mv.is_pass if pol > 0]
n_moves = int(ai_settings["pick_frac"] * len(legal_policy_moves) + ai_settings["pick_n"])
if "influence" in ai_mode or "territory" in ai_mode:
if ai_mode in [AI_INFLUENCE, AI_TERRITORY]:
thr_line = ai_settings["threshold"] - 1 # zero-based
if cn.depth >= ai_settings["endgame"] * size[0] * size[1]:
@@ -113,7 +117,7 @@ def ai_move(game: Game, ai_mode: str, ai_settings: Dict) -> Tuple[Move, GameNode
f"Generated equal weights as move number >= {ai_settings['endgame'] * size[0] * size[1]}. "
)
else:
if "influence" in ai_mode:
if ai_mode == AI_INFLUENCE:
weight = lambda x, y: (1 / ai_settings["line_weight"]) ** (
max(0, thr_line - min(size[0] - 1 - x, x)) + max(0, thr_line - min(size[1] - 1 - y, y))
)
@@ -128,7 +132,7 @@ def ai_move(game: Game, ai_mode: str, ai_settings: Dict) -> Tuple[Move, GameNode
if policy_grid[y][x] > 0
]
ai_thoughts += f"Generated weights for {ai_mode} according to weight factor {ai_settings['line_weight']} and distance from {thr_line+1}th line. "
elif "local" in ai_mode or "tenuki" in ai_mode:
elif ai_mode in [AI_LOCAL, AI_TENUKI]:
var = ai_settings["stddev"] ** 2
if not cn.move or cn.move.coords is None:
weighted_coords = [(1, 1, *top_policy_move.coords)] # if "pick" in ai_mode -> even
@@ -141,7 +145,7 @@ def ai_move(game: Game, ai_mode: str, ai_settings: Dict) -> Tuple[Move, GameNode
for y in range(size[1])
if policy_grid[y][x] > 0
]
if "tenuki" in ai_mode:
if ai_mode == AI_TENUKI:
if cn.depth < ai_settings["endgame"] * size[0] * size[1]:
weighted_coords = [(p, 1 - w, x, y) for p, w, x, y in weighted_coords]
ai_thoughts += f"Generated weights based on one minus gaussian with variance {var} around coordinates {mx},{my}. "
@@ -152,7 +156,7 @@ def ai_move(game: Game, ai_mode: str, ai_settings: Dict) -> Tuple[Move, GameNode
ai_thoughts += (
f"Generated weights based on gaussian with variance {var} around coordinates {mx},{my}. "
)
elif "pick" in ai_mode:
elif ai_mode == AI_PICK:
weighted_coords = [
(policy_grid[y][x], 1, x, y)
for x in range(size[0])
Binary file not shown.
@@ -349,6 +349,9 @@ msgstr "일반 설정"
msgid "engine settings"
msgstr "KataGo 엔진 설정"
msgid "config file path"
msgstr "설정 파일 경로: {file}"
msgid "engine:katago"
msgstr "KataGo 실행 파일 경로"
@@ -528,7 +531,3 @@ msgid "aihelp:p:territory"
msgstr ""
"`threshold`선 밑의 수를 더 많이 뽑은 후 그 중 최선의 수를 둡니다. `line_weight`을 증가시키면 바둑판 중앙에 있는"
" 수를 더욱 꺼리게 됩니다. 판이 `endgame` 비율만큼 차면 평범하게 둡니다."
#. TODO
msgid "config file path"
msgstr "설정 파일 경로: {file}"
+1
View File
@@ -116,6 +116,7 @@
Label:
SmallDescriptionLabel:
id: configfile
text: i18n._('config file path')
Label:
BackgroundMixin:
background_color: LIGHTGREY