Merge pull request #187 from sanderland/topmovegradient
Top move gradient
This commit is contained in:
5 files changed
+22
-16
No files matched your search
@@ -41,10 +41,12 @@ class KataGoEngine:
|
||||
self._lock = threading.Lock()
|
||||
self.analysis_thread = None
|
||||
self.stderr_thread = None
|
||||
self.shell = False
|
||||
|
||||
exe = config.get("katago", "").strip()
|
||||
if config.get("altcommand", ""):
|
||||
self.command = config["altcommand"]
|
||||
self.shell = True
|
||||
else:
|
||||
if not exe:
|
||||
if platform == "win":
|
||||
@@ -81,7 +83,7 @@ class KataGoEngine:
|
||||
try:
|
||||
self.katrain.log(f"Starting KataGo with {self.command}", OUTPUT_DEBUG)
|
||||
self.katago_process = subprocess.Popen(
|
||||
self.command, stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE, shell=True
|
||||
self.command, stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE, shell=self.shell
|
||||
)
|
||||
except (FileNotFoundError, PermissionError, OSError) as e:
|
||||
self.katrain.log(
|
||||
|
||||
@@ -275,7 +275,7 @@ class SGFNode:
|
||||
@property
|
||||
def next_player(self):
|
||||
"""Returns player to move"""
|
||||
if "B" in self.properties or "AB" in self.properties: # root or black moved
|
||||
if "B" in self.properties or ("AB" in self.properties and not "W" in self.properties): # root or black moved
|
||||
return "W"
|
||||
else:
|
||||
return "B"
|
||||
@@ -283,7 +283,7 @@ class SGFNode:
|
||||
@property
|
||||
def player(self):
|
||||
"""Returns player that moved last. nb root is considered white played if no handicap stones are placed"""
|
||||
if "B" in self.properties or "AB" in self.properties:
|
||||
if "B" in self.properties or ("AB" in self.properties and not "W" in self.properties):
|
||||
return "B"
|
||||
else:
|
||||
return "W"
|
||||
|
||||
+13
-10
@@ -362,7 +362,7 @@ class BadukPanWidget(Widget):
|
||||
polsize = 1.1 * math.sqrt(policy_grid[y][x])
|
||||
policy_circle_color = (
|
||||
*POLICY_COLOR,
|
||||
GHOST_ALPHA + TOP_MOVE_ALPHA * (policy_grid[y][x] == best_move_policy),
|
||||
POLICY_ALPHA + TOP_MOVE_ALPHA * (policy_grid[y][x] == best_move_policy),
|
||||
)
|
||||
draw_circle(
|
||||
(self.gridpos_x[x], self.gridpos_y[y]), polsize * self.stone_size, policy_circle_color
|
||||
@@ -385,7 +385,7 @@ class BadukPanWidget(Widget):
|
||||
text = i18n._("board-pass")
|
||||
Color(0.45, 0.05, 0.45, 0.7)
|
||||
center = (self.gridpos_x[int(board_size_x / 2)], self.gridpos_y[int(board_size_y / 2)])
|
||||
size = min(self.width, self.height) * 0.22
|
||||
size = min(self.width, self.height) * 0.227
|
||||
Ellipse(pos=(center[0] - size / 2, center[1] - size / 2), size=(size, size))
|
||||
Color(0.85, 0.85, 0.85)
|
||||
draw_text(
|
||||
@@ -395,7 +395,7 @@ class BadukPanWidget(Widget):
|
||||
self.draw_hover_contents()
|
||||
|
||||
def draw_hover_contents(self, *_args):
|
||||
ghost_alpha = GHOST_ALPHA
|
||||
ghost_alpha = POLICY_ALPHA
|
||||
katrain = self.katrain
|
||||
game_ended = katrain.game.end_result
|
||||
current_node = katrain.game.current_node
|
||||
@@ -415,17 +415,20 @@ class BadukPanWidget(Widget):
|
||||
for i, move_dict in enumerate(hint_moves):
|
||||
move = Move.from_gtp(move_dict["move"])
|
||||
if move.coords is not None:
|
||||
alpha, scale = GHOST_ALPHA, 1.0
|
||||
scale = 0.95
|
||||
if move_dict["visits"] < VISITS_FRAC_SMALL * hint_moves[0]["visits"]:
|
||||
scale = 0.8
|
||||
scale = 0.75
|
||||
if "pv" in move_dict:
|
||||
self.active_pv_moves.append((move.coords, move_dict["pv"], current_node))
|
||||
else:
|
||||
katrain.log(f"PV missing for move_dict {move_dict}", OUTPUT_DEBUG)
|
||||
draw_circle(
|
||||
(self.gridpos_x[move.coords[0]], self.gridpos_y[move.coords[1]]),
|
||||
col=[*self.eval_color(move_dict["pointsLost"])[:3], alpha],
|
||||
r=self.stone_size * scale,
|
||||
evalsize = self.stone_size * scale
|
||||
evalcol = self.eval_color(move_dict["pointsLost"])
|
||||
Color(*evalcol[:3], HINTS_ALPHA)
|
||||
Rectangle(
|
||||
pos=(self.gridpos_x[move.coords[0]] - evalsize, self.gridpos_y[move.coords[1]] - evalsize),
|
||||
size=(2 * evalsize, 2 * evalsize),
|
||||
source="katrain/img/topmove.png",
|
||||
)
|
||||
if self.trainer_config["text_point_loss"]:
|
||||
if move_dict["pointsLost"] < 0.05:
|
||||
@@ -453,7 +456,7 @@ class BadukPanWidget(Widget):
|
||||
)
|
||||
|
||||
# children of current moves in undo / review
|
||||
alpha = GHOST_ALPHA
|
||||
alpha = POLICY_ALPHA
|
||||
if katrain.analysis_controls.show_children.active:
|
||||
for child_node in current_node.children:
|
||||
points_lost = child_node.points_lost
|
||||
|
||||
@@ -31,7 +31,7 @@ EVAL_COLORS = {
|
||||
[0.447, 0.129, 0.42, 1],
|
||||
[0.8, 0, 0, 1],
|
||||
[0.9, 0.4, 0.1, 1],
|
||||
[0.85, 0.89, 0.3, 1],
|
||||
[0.95, 0.95, 0, 1],
|
||||
[0.67, 0.9, 0.18, 1],
|
||||
[0.117, 0.588, 0, 1],
|
||||
],
|
||||
@@ -39,7 +39,7 @@ EVAL_COLORS = {
|
||||
[1, 0, 1, 1],
|
||||
[1, 0, 0, 1],
|
||||
[1, 0.5, 0, 1],
|
||||
[0.85, 0.89, 0.3, 1],
|
||||
[1, 1, 0, 1],
|
||||
[0, 1, 1, 1],
|
||||
[0, 0, 1, 1],
|
||||
],
|
||||
@@ -61,7 +61,8 @@ BOARD_COLOR = [0.85, 0.68, 0.40, 1]
|
||||
STONE_SIZE = 0.505 # texture edge is transparent
|
||||
VISITS_FRAC_SMALL = 0.1
|
||||
|
||||
GHOST_ALPHA = 0.5
|
||||
POLICY_ALPHA = 0.5
|
||||
HINTS_ALPHA = 0.75
|
||||
TOP_MOVE_ALPHA = 0.4
|
||||
TOP_MOVE_BORDER_COLOR = [10 / 255, 200 / 255, 250 / 255, 1.0]
|
||||
CHILD_SCALE = 0.95
|
||||
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 45 KiB |
Reference in new issue
Block a user