diff --git a/board.py b/board.py index 848c65a..bad555a 100644 --- a/board.py +++ b/board.py @@ -56,10 +56,10 @@ class Move: else: self.analysis = analysis_blob["moveInfos"] self.ownership = analysis_blob["ownership"] - if self.parent and self.parent.analysis and self.parent.analysis[0]["move"] == self.gtp(): - self.parent.analysis[0]["scoreLead"] = self.analysis[0]["scoreLead"] - if self.children and self.children[0].analysis and self.children[0].gtp() == self.analysis[0]["move"]: - self.analysis[0]["scoreLead"] = self.children[0].analysis[0]["scoreLead"] # if received out of order, some edge case with undos ignored + if self.parent and self.parent.analysis and self.parent.analysis[0]["move"] == self.gtp(): + self.parent.analysis[0]["scoreLead"] = self.analysis[0]["scoreLead"] + if self.children and self.children[0].analysis and self.children[0].gtp() == self.analysis[0]["move"]: + self.analysis[0]["scoreLead"] = self.children[0].analysis[0]["scoreLead"] # if received out of order, some edge case with undos ignored @property def analysis_ready(self): diff --git a/config.json b/config.json index 1f3b250..0c94dcd 100644 --- a/config.json +++ b/config.json @@ -25,7 +25,8 @@ "starpoint_size": 0.1, "stone_size": 0.475, "board_color": [0.85, 0.68, 0.40], - "line_color": [0,0,0] + "line_color": [0,0,0], + "min_eval_temperature": 0.5 }, "engine": { "command": "KataGo/katago analysis -model models/b10-1.3.gz -config KataGo/analysis_config.cfg -analysis-threads 8" diff --git a/controller.py b/controller.py index 161fd61..4c94124 100644 --- a/controller.py +++ b/controller.py @@ -82,18 +82,22 @@ class EngineControls(GridLayout): self._request_analysis(mr, faster=faster) return mr + def show_evaluation_stats(self, move): + if move.analysis_ready: + self.score.text = move.format_score().replace("-", "\u2013") + self.temperature.text = f"{move.temperature_stats[2]:.1f}" + if move.parent and move.parent.analysis_ready: + self.evaluation.text = f"{move.evaluation:.1%}" + # handles showing completed analysis and triggered actions like auto undo and ai move def update_evaluation(self, undo_triggered=False): current_move = self.board.current_move self.score.set_prisoners(self.board.prisoner_count) - if self.eval.active(current_move.player): + if self.eval.active(current_move.player) and current_move is not self.board.root: self.info.text = current_move.comment(eval=self.eval.active(current_move.player), hints=self.hints.active(current_move.player)) self.evaluation.text = "" - if current_move.analysis_ready and self.eval.active(current_move.player): - self.score.text = current_move.format_score().replace("-", "\u2013") - self.temperature.text = f"{current_move.temperature_stats[2]:.1f}" - if current_move.parent and current_move.parent.analysis_ready: - self.evaluation.text = f"{current_move.evaluation:.1%}" + if self.eval.active(current_move.player): + self.show_evaluation_stats(current_move) if current_move.analysis_ready and current_move.parent and current_move.parent.analysis_ready and not current_move.children: # handle automatic undo @@ -180,7 +184,7 @@ class EngineControls(GridLayout): self._send_analysis_query(self.outstanding_analysis_queries.pop(0)) line = self.kata.stdout.readline() if self.debug: - print("KATA ANALYSIS RECEIVED:", line[:50], "...") + print("KATA ANALYSIS RECEIVED:", line[:80], "...") if not line: # occasionally happens? return try: @@ -215,7 +219,7 @@ class EngineControls(GridLayout): "maxVisits": self.visits[fast][1] // faster_fac, } if self.debug: - print(f"query for {move_id}") + print(f"sending query for move {move_id}: {str(query)[:80]}") self._send_analysis_query(query) query.update({"id": f"PASS_{move_id}", "maxVisits": self.visits[fast][0] // faster_fac, "includeOwnership": False}) query["moves"] += [[move.bw_player(next_move=True), "pass"]] diff --git a/katrain.py b/katrain.py index c05d7a0..79eed9c 100644 --- a/katrain.py +++ b/katrain.py @@ -54,6 +54,7 @@ class BadukPanWidget(Widget): stones_here = [m for m in self.engine.board.stones if m.coords == (xp, yp)] if stones_here and max(yd, xd) < self.grid_size / 2: # load old comment self.engine.info.text = stones_here[-1].comment(sgf=True) + self.engine.show_evaluation_stats(stones_here[-1]) if self.engine.debug: print("\nAnalysis:\n", stones_here[-1].analysis) print("\nParent Analysis:\n", stones_here[-1].parent.analysis) @@ -129,7 +130,7 @@ class BadukPanWidget(Widget): for i, m in enumerate(self.engine.board.stones): has_stone[m.coords] = m.player eval, evalsize = m.evaluation_info - evalcol = self._eval_spectrum(eval) if eval_on[m.player] and eval else None + evalcol = self._eval_spectrum(eval) if eval_on[m.player] and eval and evalsize > Config.get("ui").get("min_eval_temperature", 0.5) else None inner = COLORS[1 - m.player] if (m == last_move) else None self.draw_stone(m.coords[0], m.coords[1], COLORS[m.player], inner, evalcol, evalsize)