sgf notes

This commit is contained in:
Sander Land committed 2020-05-16 21:30:37 +02:00
1 parent c1ac44c489
commit 7ee1db1f5b
5 files changed
+22 -8

No files matched your search

+7 -3
View File
@@ -147,6 +147,9 @@ class KaTrainGui(BoxLayout):
self.board_gui.redraw_board_contents_trigger()
self.controls.update_evaluation()
def set_note(self, note):
self.game.current_node.note = note
def _message_loop_thread(self):
while True:
game, msg, *args = self.message_queue.get()
@@ -189,6 +192,7 @@ class KaTrainGui(BoxLayout):
self.game.redo(n_times)
def _do_switch_branch(self, direction):
self.board_gui.animating_pv = None
self.game.switch_branch(direction)
def _do_play(self, coords):
@@ -276,7 +280,7 @@ class KaTrainGui(BoxLayout):
return super().on_touch_up(touch)
def _on_keyboard_down(self, _keyboard, keycode, _text, modifiers):
if isinstance(App.get_running_app().root_window.children[0], Popup):
if isinstance(App.get_running_app().root_window.children[0], Popup) or self.controls.note.focus:
return # if in new game or load, don't allow keyboard shortcuts
shortcuts = {
@@ -335,11 +339,11 @@ class KaTrainApp(App):
def on_start(self):
self.gui.start()
def on_request_close(self, *args):
def on_request_close(self, *_args):
if getattr(self, "gui", None) and self.gui.engine:
self.gui.engine.shutdown()
def signal_handler(self, *args):
def signal_handler(self, _signal, _frame):
if self.gui.debug_level >= OUTPUT_DEBUG:
print("TRACEBACKS")
for threadId, stack in sys._current_frames().items():
+5 -2
View File
@@ -16,6 +16,7 @@ class GameNode(SGFNode):
self.policy = None
self.auto_undo = None # None = not analyzed. False: not undone (good move). True: undone (bad move)
self.ai_thoughts = ""
self.note = ""
self.move_number = 0
self.undo_threshold = random.random() # for fractional undos, store the random threshold in the move itself for consistency
self._favourite_child = None
@@ -36,13 +37,15 @@ class GameNode(SGFNode):
properties["MA"] = [top_x]
comment = self.comment(sgf=True, interactive=False)
if comment:
properties["C"] = [properties.get("C", "") + comment]
properties["C"] = ["\n".join(properties.get("C", "")) + comment]
if self.is_root:
properties["C"] = [
"Moves marked 'X' indicate the top move according to KataGo, those with a square are moves that lose less than 0.5 points.\n"
+ "\n".join(properties.get("C", ""))
+ "\nSGF with review generated by KaTrain."
]
if self.note.strip():
properties["C"] = ["\n".join(properties.get("C", "")) + f"\nNote: {self.note}"]
return properties
@staticmethod
@@ -83,7 +86,7 @@ class GameNode(SGFNode):
self.policy = analysis_json.get("policy")
self.analysis["root"] = analysis_json["rootInfo"]
if self.parent and self.move:
analysis_json["rootInfo"]['pv'] = [self.move.gtp()] + (analysis_json["moveInfos"][0]["pv"] if analysis_json["moveInfos"] else [])
analysis_json["rootInfo"]["pv"] = [self.move.gtp()] + (analysis_json["moveInfos"][0]["pv"] if analysis_json["moveInfos"] else [])
self.parent.update_move_analysis(analysis_json["rootInfo"], self.move.gtp()) # update analysis in parent for consistency
@property
+8 -1
View File
@@ -409,6 +409,7 @@
play_tab_button: play_tab_button
analyze_tab_button: analyze_tab_button
info: info
note: note
status_label: status_label
win_rate: win_rate
score_change: score_change
@@ -623,7 +624,13 @@
markup: True
on_ref_press: root.katrain.board_gui.show_pv_from_comments(args[1])
size_hint: 1, None
height: self.parent.height - status_label.height - 1
height: self.parent.height - status_label.height - note.height - 1
TextInput:
id: note
size_hint: 1, None
on_text: root.katrain.set_note(self.text)
hint_text: 'Your SGF notes for this position here.'
height: min( (len(self._lines)+0.7) * self.line_height, self.parent.height - status_label.height - 2.7*self.line_height)
BoxLayout:
orientation: 'horizontal'
size_hint: 1, None
+1 -1
View File
@@ -330,7 +330,7 @@ class BadukPanWidget(Widget):
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)
katrain.log(f"PV missing for move_dict {move_dict}", OUTPUT_DEBUG)
self.draw_stone(move.coords[0], move.coords[1], [*self.eval_color(move_dict["pointsLost"])[:3], alpha], scale=scale)
# hover next move ghost stone
+1 -1
View File
@@ -91,7 +91,7 @@ class Controls(BoxLayout):
self.win_rate.text = current_node.parent.format_win_rate()
self.graph.update_value(current_node)
self.note.text = current_node.note
self.info.text = info
def configure_ais(self):