diff --git a/.gitignore b/.gitignore index ea3ff0e..031afa5 100644 --- a/.gitignore +++ b/.gitignore @@ -16,6 +16,8 @@ tmp.pickle my logs callgrind.* +cpp/out +.vs # debug outdated_log.txt diff --git a/katrain/KataGo/katago b/katrain/KataGo/katago deleted file mode 100755 index 99298c0..0000000 Binary files a/katrain/KataGo/katago and /dev/null differ diff --git a/katrain/KataGo/katago.exe b/katrain/KataGo/katago.exe index b416e3c..77be7b7 100644 Binary files a/katrain/KataGo/katago.exe and b/katrain/KataGo/katago.exe differ diff --git a/katrain/core/ai.py b/katrain/core/ai.py index 0183c12..d2ae41a 100644 --- a/katrain/core/ai.py +++ b/katrain/core/ai.py @@ -357,19 +357,26 @@ def generate_ai_move(game: Game, ai_mode: str, ai_settings: Dict) -> Tuple[Move, aimove = topmove[2] ai_thoughts += f"ScoreLoss strategy found {len(candidate_ai_moves)} candidate moves (best {top_cand.gtp()}) and chose {aimove.gtp()} (weight {topmove[1]:.3f}, point loss {topmove[0]:.1f}) based on score weights." elif ai_mode == AI_SIMPLE_OWNERSHIP: - last_player_stones = {s.coords for s in game.stones if s.player == cn.player} + stones_with_player = {(*s.coords, s.player) for s in game.stones} next_player_sign = cn.player_sign(cn.next_player) def settledness(d, player_sign): return sum([abs(o) for o in d["ownership"] if player_sign * o > 0]) - def is_attachment(d): - return any( - (d.coords[0] + dx, d.coords[1] + dy) in last_player_stones + def is_attachment(move): + attach_opponent_stones = sum( + (move.coords[0] + dx, move.coords[1] + dy, cn.player) in stones_with_player for dx in [-1, 0, 1] for dy in [-1, 0, 1] if abs(dx) + abs(dy) == 1 ) + nearby_own_stones = sum( + (move.coords[0] + dx, move.coords[1] + dy, cn.next_player) in stones_with_player + for dx in [-2, 0, 1, 2] + for dy in [-2 - 1, 0, 1, 2] + if abs(dx) + abs(dy) <= 2 # allows clamps/jumps + ) + return attach_opponent_stones >= 1 and nearby_own_stones == 0 def is_tenuki(d): return not any( diff --git a/katrain/core/constants.py b/katrain/core/constants.py index c31a41d..05b80ba 100644 --- a/katrain/core/constants.py +++ b/katrain/core/constants.py @@ -95,7 +95,16 @@ AI_OPTION_VALUES = { "attach_penalty": [x / 10 for x in range(-10, 51)], "tenuki_penalty": [x / 10 for x in range(-10, 51)], } -AI_KEY_PROPERTIES = {"kyu_rank", "strength", "weaken_fac", "pick_frac", "pick_n", "automatic","max_points_lost","min_visits"} +AI_KEY_PROPERTIES = { + "kyu_rank", + "strength", + "weaken_fac", + "pick_frac", + "pick_n", + "automatic", + "max_points_lost", + "min_visits", +} CALIBRATED_RANK_ELO = [ diff --git a/katrain/gui/badukpan.py b/katrain/gui/badukpan.py index 35cb671..e5d48b4 100644 --- a/katrain/gui/badukpan.py +++ b/katrain/gui/badukpan.py @@ -106,7 +106,7 @@ class BadukPanWidget(Widget): return katrain = self.katrain if self.ghost_stone and ("button" not in touch.profile or touch.button == "left"): - game = self.katrain and self.katrain.game + game = self.katrain and self.katrain.game current_node = game and self.katrain.game.current_node if ( current_node @@ -114,7 +114,7 @@ class BadukPanWidget(Widget): and not self.katrain.next_player_info.ai and not self.katrain.controls.timer.paused and self.katrain.play_analyze_mode == MODE_PLAY - and self.katrain.config("timer/main_time",0) * 60 - game.main_time_used <= 0 + and self.katrain.config("timer/main_time", 0) * 60 - game.main_time_used <= 0 and current_node.time_used < self.katrain.config("timer/minimal_use", 0) ): self.katrain.controls.set_status(