Skip to content

Commit f1fc1a2

Browse files
committed
feature: add shortcut m for toggle the move num of nodes
1 parent 98ce47c commit f1fc1a2

File tree

3 files changed

+18
-1
lines changed

3 files changed

+18
-1
lines changed

katrain/__main__.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,8 @@ def __init__(self, **kwargs):
124124
self.contribute_popup = None
125125

126126
self.pondering = False
127+
self.move_num = False
128+
127129
self.animate_contributing = False
128130
self.message_queue = Queue()
129131

@@ -173,6 +175,10 @@ def toggle_continuous_analysis(self, quiet=False):
173175
self.pondering = not self.pondering
174176
self.update_state()
175177

178+
def toggle_move_num(self):
179+
self.move_num = not self.move_num
180+
self.update_state()
181+
176182
def start(self):
177183
if self.engine:
178184
return
@@ -740,6 +746,8 @@ def _on_keyboard_down(self, _keyboard, keycode, _text, modifiers):
740746

741747
if keycode[1] == Theme.KEY_TOGGLE_CONTINUOUS_ANALYSIS:
742748
self.toggle_continuous_analysis(quiet=shift_pressed)
749+
elif keycode[1] == Theme.KEY_TOGGLE_MOVENUM:
750+
self.toggle_move_num()
743751
elif keycode[1] == Theme.KEY_TOGGLE_COORDINATES:
744752
self.board_gui.toggle_coordinates()
745753
elif keycode[1] in Theme.KEY_PAUSE_TIMER and not ctrl_pressed:

katrain/gui/badukpan.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -227,7 +227,7 @@ def redraw(self, *_args):
227227
self.draw_board_contents()
228228

229229
def draw_stone(
230-
self, x, y, player, alpha=1, innercol=None, evalcol=None, evalscale=1.0, scale=1.0, ownership=None, loss=None
230+
self, x, y, player, alpha=1, innercol=None, evalcol=None, evalscale=1.0, scale=1.0, ownership=None, loss=None,depth=None
231231
):
232232
stone_size = self.stone_size * scale
233233
if ownership is not None:
@@ -297,6 +297,11 @@ def draw_stone(
297297
texture=cached_texture(Theme.LAST_MOVE_TEXTURE),
298298
)
299299

300+
if depth:
301+
text = str(depth)
302+
Color(*Theme.NUMBER_COLOR)
303+
draw_text(pos=self.gridpos[y][x], text=text, font_size=self.stone_size*0.9, font_name="Roboto")
304+
300305
def eval_color(self, points_lost, show_dots_for_class: List[bool] = None) -> Optional[List[float]]:
301306
i = evaluation_class(points_lost, self.trainer_config["eval_thresholds"])
302307
colors = Theme.EVAL_COLORS[self.trainer_config["theme"]]
@@ -663,6 +668,7 @@ def draw_board_contents(self, *_args):
663668
if ownership_grid and not loss_grid and not new_move
664669
else None,
665670
loss=loss_grid[m.coords[1]][m.coords[0]] if loss_grid else None,
671+
depth=node.depth if katrain.move_num else None,
666672
)
667673
realized_points_lost = node.parent_realized_points_lost
668674

katrain/gui/theme.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,8 @@ class Theme:
108108
PASS_CIRCLE_TEXT_COLOR = [0.85, 0.85, 0.85]
109109

110110
STONE_COLORS = {"B": BLACK, "W": WHITE}
111+
NUMBER_COLOR = [0.85, 0.68, 0.40, 0.8]
112+
111113
NEXT_MOVE_DASH_CONTRAST_COLORS = {"B": LIGHTER_GREY, "W": GREY}
112114
OUTLINE_COLORS = {"B": [0.3, 0.3, 0.3, 0.5], "W": [0.7, 0.7, 0.7, 0.5]}
113115
PV_TEXT_COLORS = {"W": BLACK, "B": WHITE} # numbers in PV
@@ -198,6 +200,7 @@ class Theme:
198200
KEY_SELFPLAY_TO_END = "l"
199201
KEY_STOP_ANALYSIS = "escape"
200202
KEY_TOGGLE_CONTINUOUS_ANALYSIS = "spacebar"
203+
KEY_TOGGLE_MOVENUM = "m"
201204

202205
KEY_COPY = "c"
203206
KEY_PASTE = "v"

0 commit comments

Comments
 (0)