diff --git a/engine.py b/engine.py index 5568e4e..30cafac 100644 --- a/engine.py +++ b/engine.py @@ -51,6 +51,8 @@ class KataGoEngine: def _analysis_read_thread(self): while True: line = self.katago_process.stdout.readline() + if b"Uncaught exception" in line: + self.katrain.log(f"KataGo Engine Failed: {line.decode()}",OUTPUT_ERROR) if not line: continue analysis = json.loads(line) @@ -69,6 +71,7 @@ class KataGoEngine: def request_analysis( self, analysis_node: GameNode, callback: Callable, faster=False, min_visits=0, priority=0, ownership=None ): + self.fast = self.katrain.controls.ai_fast.active query_id = f"QUERY:{str(self.query_counter)}" self.query_counter += 1 visits = 100 # TODO / fast = self.ai_fast.active diff --git a/game.py b/game.py index 237c0ff..a205762 100644 --- a/game.py +++ b/game.py @@ -39,7 +39,8 @@ class Game: else: self.board_size = board_size or config['size'] self.komi = self.config.get(f"komi_{self.board_size}",6.5) - self.root = GameNode(properties={"GM":1,"FF":4,"RU": "JP", "SZ": self.board_size, "KM": self.komi, "AP": "[KaTrain:https://github.com/sanderland/katrain]", "DT": self.game_id}) + self.root = GameNode(properties={"GM":1,"FF":4,"RU": "JP", "SZ": self.board_size, "KM": self.komi, + "AP": "KaTrain:https://github.com/sanderland/katrain", "DT": self.game_id}) self.current_node = self.root self._init_chains() diff --git a/gui/badukpan.py b/gui/badukpan.py index 1db7750..9cc4139 100644 --- a/gui/badukpan.py +++ b/gui/badukpan.py @@ -177,7 +177,7 @@ class BadukPanWidget(Widget): for child_node in current_node.children: points_lost = child_node.points_lost m = child_node.single_move - if m and m.coords[0] is not None: + if m and m.coords is not None: undo_coords.add(m.coords) evalcol = (*self.eval_color(points_lost), alpha) if points_lost is not None else None scale = self.config.get("undo_scale", 0.95) @@ -189,7 +189,7 @@ class BadukPanWidget(Widget): for i, d in enumerate(hint_moves): move = Move.from_gtp(d["move"]) c = [*self.eval_color(d["pointsLost"]), 0.5] - if move.coords[0] is not None and move.coords not in undo_coords: + if move.coords is not None and move.coords not in undo_coords: if i == 0: scale = 1.0 elif d["visits"] < 0.1 * hint_moves[0]["visits"]: # TODO: config? diff --git a/katrain.kv b/katrain.kv index 6c0d13c..421dfa2 100644 --- a/katrain.kv +++ b/katrain.kv @@ -338,17 +338,17 @@ size_hint: 0.233, 1 text: '9' margin: (1,1) - on_press: root.restart(9) + on_press: root.parent('new-game',9) StyledButton: size_hint: 0.233, 1 text: '13' margin: (0,1) - on_press: root.restart(13) + on_press: root.parent('new-game',13) StyledButton: size_hint: 0.233, 1 text: '19' margin: (1,1) - on_press: root.restart(19) + on_press: root.parent('new-game',19) : board_gui: board_gui diff --git a/katrain.py b/katrain.py index 59fb459..20062eb 100644 --- a/katrain.py +++ b/katrain.py @@ -157,7 +157,7 @@ class KaTrainGui(BoxLayout): def redraw(self, include_board=False): # TODO: rename? does more now cn = self.game.current_node - if cn.analysis_ready and self.controls.ai_auto.active(cn.next_player) and not cn.children: + if cn.analysis_ready and self.controls.ai_auto.active(cn.next_player) and not cn.children and not self.game.game_ended: self._do_aimove() if include_board: diff --git a/sgf_parser.py b/sgf_parser.py index 3c8aae8..a8b7ea8 100644 --- a/sgf_parser.py +++ b/sgf_parser.py @@ -77,6 +77,8 @@ class SGFNode: return copy.deepcopy(self.properties) def sgf(self) -> str: + import sys # TODO + sys.setrecursionlimit(max(sys.getrecursionlimit(),3*29*29)) sgf_str = "".join([prop + "".join(f"[{v}]" for v in values) for prop, values in self.sgf_properties.items() if values]) if self.children: children = [c.sgf() for c in self.children]