diff --git a/katrain/__main__.py b/katrain/__main__.py index 5dd6f62a..3b864a8c 100644 --- a/katrain/__main__.py +++ b/katrain/__main__.py @@ -159,6 +159,7 @@ def update_gui(self, cn, redraw_board=False): self.board_controls.mid_circles_container.add_widget(top) self.board_controls.branch.disabled = not cn.parent or len(cn.parent.children) <= 1 self.controls.players["W"].captures = prisoners["W"] + self.controls.players["W"].komi = self.game.komi self.controls.players["B"].captures = prisoners["B"] # update engine status dot diff --git a/katrain/core/base_katrain.py b/katrain/core/base_katrain.py index 627a3def..e8604a87 100644 --- a/katrain/core/base_katrain.py +++ b/katrain/core/base_katrain.py @@ -61,8 +61,8 @@ def __init__(self, force_package_config=False, debug_level=0, **kwargs): if self.debug_level >= OUTPUT_DEBUG: Config.set("kivy", "log_enable", 1) Config.set("kivy", "log_level", "debug") - if self.debug_level >= OUTPUT_EXTRA_DEBUG: - Config.set("kivy", "log_level", "trace") + # if self.debug_level >= OUTPUT_EXTRA_DEBUG: + # Config.set("kivy", "log_level", "trace") self.players_info = {"B": Player("B"), "W": Player("W")} self.reset_players() diff --git a/katrain/core/engine.py b/katrain/core/engine.py index 89714c8f..e3525614 100644 --- a/katrain/core/engine.py +++ b/katrain/core/engine.py @@ -226,8 +226,9 @@ def request_analysis( next_move: Optional[GameNode] = None, extra_settings: Optional[Dict] = None, ): - moves = [m for node in analysis_node.nodes_from_root for m in node.moves] - initial_stones = analysis_node.root.placements + nodes = analysis_node.nodes_from_root + moves = [m for node in nodes for m in node.moves] + initial_stones = [m for node in nodes for m in node.placements] if next_move: moves.append(next_move) if ownership is None: diff --git a/katrain/core/game.py b/katrain/core/game.py index 21ed7fd6..daef7e89 100644 --- a/katrain/core/game.py +++ b/katrain/core/game.py @@ -55,7 +55,11 @@ def __init__( self.root = move_tree self.komi = self.root.komi handicap = int(self.root.get_property("HA", 0)) - if handicap >= 2 and not self.root.placements: + if ( + handicap >= 2 + and not self.root.placements + and not (not self.root.move_with_placements and self.root.children and self.root.children[0].placements) + ): # not really according to sgf, and not sure if still needed, last clause for fox self.root.place_handicap_stones(handicap) else: board_size = katrain.config("game/size") @@ -310,7 +314,9 @@ def analyze_extra(self, mode, **kwargs): if mode == "extra": if kwargs.get("continuous", False): - visits = max(engine.config["max_visits"], math.ceil(cn.analysis_visits_requested * 1.25)) + visits = min( + 1_000_000_000, max(engine.config["max_visits"], math.ceil(cn.analysis_visits_requested * 1.25)) + ) else: visits = cn.analysis_visits_requested + engine.config["max_visits"] self.katrain.controls.set_status(i18n._("extra analysis").format(visits=visits), STATUS_ANALYSIS) diff --git a/katrain/core/sgf_parser.py b/katrain/core/sgf_parser.py index 000809e8..5256c049 100644 --- a/katrain/core/sgf_parser.py +++ b/katrain/core/sgf_parser.py @@ -333,9 +333,15 @@ def parse_sgf(cls, input_str) -> SGFNode: match = re.search(cls.SGF_PAT, input_str) clipped_str = match.group() if match else input_str root = cls(clipped_str).root + # Fix weird FoxGo server KM values if "foxwq" in root.get_list_property("AP"): - fixed_komi = 0.5 if root.get_property("HA") == 1 else 7.5 - root.set_property("KM", fixed_komi) + if int(root.get_property("HA", 0)) >= 1: + corrected_komi = 0.5 + elif root.get_property("RU").lower() in ["chinese", "cn"]: + corrected_komi = 7.5 + else: + corrected_komi = 6.5 + root.set_property("KM", corrected_komi) return root @classmethod diff --git a/katrain/gui.kv b/katrain/gui.kv index 407e970a..40ade7fe 100644 --- a/katrain/gui.kv +++ b/katrain/gui.kv @@ -277,16 +277,25 @@ : captures: 0 player: 'B' + komi: 0 player_type: 'player:human' player_subtype: 'game:normal' background_color: BOX_BACKGROUND_COLOR if self.active else BACKGROUND_COLOR outline_color: BOX_BACKGROUND_COLOR outline_width: 2 padding: [2*CP_PADDING,CP_PADDING,CP_PADDING,CP_PADDING] - CircleWithText: - player: root.player - text: str(root.captures) + BoxLayout: size_hint: 0.32, 1 + orientation: 'vertical' + CircleWithText: + player: root.player + text: str(root.captures) + Label: + size_hint: 1,0.25 + halign: 'center' + valign: 'middle' + font_size: self.height + text: "%s: %.1f" % (i18n._('komi'), root.komi) if root.player=='W' else '' BoxLayout: size_hint: 0.75, 1 pos_hint: {'x':0,'y':0} diff --git a/katrain/gui/kivyutils.py b/katrain/gui/kivyutils.py index 5da05489..678759cb 100644 --- a/katrain/gui/kivyutils.py +++ b/katrain/gui/kivyutils.py @@ -338,6 +338,7 @@ class PlayerInfo(MDBoxLayout, BackgroundMixin): captures = NumericProperty(0) player = OptionProperty("B", options=["B", "W"]) player_type = StringProperty("Player") + komi = NumericProperty(0) player_subtype = StringProperty("") name = StringProperty("", allownone=True) rank = StringProperty("", allownone=True)