diff --git a/i18n.py b/i18n.py index 37f1dc0..def6029 100644 --- a/i18n.py +++ b/i18n.py @@ -1,7 +1,8 @@ +import copy +import glob import os import re import sys -import copy from collections import defaultdict import polib @@ -100,4 +101,13 @@ for lang in locales: print("Fixed", pofile[lang], "and converted ->", mofile) +for file in glob.glob("katrain/**/*.py") + glob.glob("katrain/**/*.kv"): + with open(file, "r") as f: + for i, line in enumerate(f.readlines()): + matches = [m.strip() for m in re.findall(r"i18n._\((.*?)\)", line)] + for msgid in matches: + if msgid[0] in ['"', "'"] and msgid.strip("\"'") not in strings_to_langs: # not code + print(f"Missing {msgid} used in code at \t{file}:{i} \t'{line.strip()}'") + errors += 1 + sys.exit(int(errors)) diff --git a/katrain/__main__.py b/katrain/__main__.py index 44b0bde..756909b 100644 --- a/katrain/__main__.py +++ b/katrain/__main__.py @@ -273,6 +273,11 @@ class KaTrainGui(Screen, KaTrainBase): # self.controls.rank_graph.initialize_from_game(self.game.root) self.update_state(redraw_board=True) + def _do_insert_mode(self, mode="toggle"): + self.game.set_insert_mode(mode) + if self.play_analyze_mode != MODE_ANALYZE: + self.play_mode.switch_ui_mode() + def _do_ai_move(self, node=None): if node is None or self.game.current_node == node: mode = self.next_player_info.strategy @@ -485,6 +490,7 @@ class KaTrainGui(Screen, KaTrainBase): "d": ("analyze-extra", "sweep"), "f": ("analyze-extra", "alternative"), "g": ("analyze-extra", "local"), + "i": ("insert-mode",), "p": ("play", None), "n": ("next-mistake",), "down": ("switch-branch", 1), diff --git a/katrain/config.json b/katrain/config.json index 0ba024b..22ad83d 100644 --- a/katrain/config.json +++ b/katrain/config.json @@ -98,14 +98,6 @@ "attach_penalty": 1, "tenuki_penalty": 0.5 }, - "ai:settle": { - "max_points_lost": 1.75, - "settled_weight": 1.0, - "opponent_fac": 0.5, - "min_visits": 3, - "attach_penalty": 1, - "tenuki_penalty": 0.5 - }, "ai:p:weighted": { "weaken_fac": 1.25, "pick_override": 1.0, diff --git a/katrain/core/ai.py b/katrain/core/ai.py index b15a1d6..8c7da85 100644 --- a/katrain/core/ai.py +++ b/katrain/core/ai.py @@ -18,6 +18,7 @@ from katrain.core.constants import ( AI_RANK, AI_SCORELOSS, AI_SCORELOSS_ELO, + AI_SETTLE_STONES, AI_SIMPLE_OWNERSHIP, AI_STRATEGIES_PICK, AI_STRATEGIES_POLICY, @@ -32,7 +33,6 @@ from katrain.core.constants import ( OUTPUT_DEBUG, OUTPUT_ERROR, OUTPUT_INFO, - AI_SETTLE_STONES, ) from katrain.core.game import Game, GameNode, Move from katrain.core.utils import var_to_grid diff --git a/katrain/core/game.py b/katrain/core/game.py index 2d5c8f4..65519db 100644 --- a/katrain/core/game.py +++ b/katrain/core/game.py @@ -1,3 +1,4 @@ +import copy import math import os import re @@ -8,17 +9,18 @@ from typing import Dict, List, Optional, Union from kivy.clock import Clock from katrain.core.constants import ( + ANALYSIS_FORMAT_VERSION, HOMEPAGE, OUTPUT_DEBUG, OUTPUT_INFO, PLAYER_AI, + PLAYER_HUMAN, + PROGRAM_NAME, STATUS_ANALYSIS, + STATUS_ERROR, STATUS_INFO, STATUS_TEACHING, - PLAYER_HUMAN, VERSION, - PROGRAM_NAME, - ANALYSIS_FORMAT_VERSION, ) from katrain.core.engine import KataGoEngine from katrain.core.game_node import GameNode @@ -57,6 +59,9 @@ class Game: self.game_id = datetime.strftime(datetime.now(), "%Y-%m-%d %H %M %S") self.sgf_filename = sgf_filename + self.insert_mode = False + self.insert_after = None + if move_tree: self.root = move_tree self.komi = self.root.komi @@ -165,6 +170,55 @@ class Game: if -1 not in neighbours(self.chains[this_chain]): # TODO: NZ rules? raise IllegalMoveException("Suicide") + def set_insert_mode(self, mode): + if mode == "toggle": + mode = not self.insert_mode + if mode == self.insert_mode: + return + self.insert_mode = mode + if mode: + children = self.current_node.ordered_children + if not children: + self.insert_mode = False + else: + self.insert_after = self.current_node.ordered_children[0] + self.katrain.controls.set_status(i18n._("starting insert mode"), STATUS_INFO) + else: + copy_from_node = self.insert_after + copy_to_node = self.current_node + num_copied = 0 + if copy_to_node != self.insert_after.parent: + above_insertion_root = self.insert_after.parent.nodes_from_root + already_inserted_moves = [ + n.move for n in copy_to_node.nodes_from_root if n not in above_insertion_root and n.move + ] + print(already_inserted_moves) + try: + while True: + if copy_from_node.move not in already_inserted_moves: + for m in copy_from_node.move_with_placements: + self._validate_move_and_update_chains(m, True) + # this inserts + copy_to_node = GameNode( + parent=copy_to_node, properties=copy.deepcopy(copy_from_node.properties) + ) + num_copied += 1 + if not copy_from_node.children: + break + copy_from_node = copy_from_node.ordered_children[0] + except: + pass # illegal move = stop + self._calculate_groups() # recalculate groups + self.katrain.controls.set_status( + i18n._("ending insert mode").format(num_copied=num_copied), STATUS_INFO + ) + self.analyze_all_nodes(analyze_fast=True, even_if_present=False) + else: + self.katrain.controls.set_status("", STATUS_INFO) + self.katrain.controls.move_tree.insert_node = self.insert_after if self.insert_mode else None + self.katrain.controls.move_tree.redraw() + self.katrain.update_state(redraw_board=True) + # Play a Move from the current position, raise IllegalMoveException if invalid. def play(self, move: Move, ignore_ko: bool = False, analyze=True): board_size_x, board_size_y = self.board_size @@ -183,17 +237,31 @@ class Game: return played_node def set_current_node(self, node): + if self.insert_mode: + self.katrain.controls.set_status(i18n._("finish inserting before navigating"), STATUS_ERROR) + return + self.current_node = node self._calculate_groups() def undo(self, n_times=1): + # allow undo/delete only in insert mode cn = self.current_node # avoid race conditions + if self.insert_mode: + if n_times == 1 and cn not in self.insert_after.nodes_from_root: + cn.parent.children = [c for c in cn.parent.children if c != cn] + self.current_node = cn.parent + self._calculate_groups() + return + for _ in range(n_times): if not cn.is_root: cn = cn.parent self.set_current_node(cn) def redo(self, n_times=1, stop_on_mistake=None): + if self.insert_mode: + return cn = self.current_node # avoid race conditions for move in range(n_times): if cn.children: diff --git a/katrain/core/game_node.py b/katrain/core/game_node.py index 341f7bb..dfee82b 100644 --- a/katrain/core/game_node.py +++ b/katrain/core/game_node.py @@ -1,21 +1,21 @@ +import base64 import copy +import gzip +import json import random from typing import Dict, List, Optional, Tuple from katrain.core.constants import ( - VERSION, + ANALYSIS_FORMAT_VERSION, + PROGRAM_NAME, SGF_INTERNAL_COMMENTS_MARKER, SGF_SEPARATOR_MARKER, - PROGRAM_NAME, - ANALYSIS_FORMAT_VERSION, + VERSION, ) from katrain.core.lang import i18n from katrain.core.sgf_parser import Move, SGFNode -from katrain.core.utils import evaluation_class, var_to_grid, pack_floats, unpack_floats +from katrain.core.utils import evaluation_class, pack_floats, unpack_floats, var_to_grid from katrain.gui.style import INFO_PV_COLOR -import base64 -import gzip -import json def analysis_dumps(analysis): diff --git a/katrain/gui.kv b/katrain/gui.kv index bdf1e73..209d633 100644 --- a/katrain/gui.kv +++ b/katrain/gui.kv @@ -755,6 +755,11 @@ icon: 'img/local.png' shortcut: 'g' on_action: root.katrain("analyze-extra", "local") + AnalysisMenuItem: + text: i18n._("analysis:insert") + icon: 'img/local.png' + shortcut: 'i' + on_action: root.katrain("insert-mode") AnalysisMenuItem: text: i18n._("analysis:game") icon: 'img/analysis.png' diff --git a/katrain/gui/badukpan.py b/katrain/gui/badukpan.py index 26a08a1..40b06e4 100644 --- a/katrain/gui/badukpan.py +++ b/katrain/gui/badukpan.py @@ -20,19 +20,19 @@ from kivymd.uix.floatlayout import MDFloatLayout from katrain.core.constants import ( MODE_PLAY, OUTPUT_DEBUG, - STATUS_TEACHING, OUTPUT_EXTRA_DEBUG, - TOP_MOVE_OPTIONS, - TOP_MOVE_NOTHING, + STATUS_TEACHING, TOP_MOVE_DELTA_SCORE, - TOP_MOVE_SCORE, - TOP_MOVE_WINRATE, TOP_MOVE_DELTA_WINRATE, + TOP_MOVE_NOTHING, + TOP_MOVE_OPTIONS, + TOP_MOVE_SCORE, TOP_MOVE_VISITS, + TOP_MOVE_WINRATE, ) from katrain.core.game import Move from katrain.core.lang import i18n -from katrain.core.utils import evaluation_class, var_to_grid, format_visits +from katrain.core.utils import evaluation_class, format_visits, var_to_grid from katrain.gui.kivyutils import BackgroundMixin, draw_circle, draw_text from katrain.gui.popups import I18NPopup, ReAnalyzeGamePopup from katrain.gui.style import * @@ -226,7 +226,10 @@ class BadukPanWidget(Widget): for i in range(board_size_y) ] - Color(1, 0.95, 0.8, 1) # image is a bit too light + if katrain.game.insert_mode: + Color(1, 1, 1, 0.75) # dreamy + else: + Color(1, 0.95, 0.8, 1) # image is a bit too light Rectangle( pos=(self.gridpos_x[0] - self.grid_size * 1.5, self.gridpos_y[0] - self.grid_size * 1.5), size=(self.grid_size * x_grid_spaces, self.grid_size * y_grid_spaces), diff --git a/katrain/gui/controlspanel.py b/katrain/gui/controlspanel.py index 9d5d45a..652a84d 100644 --- a/katrain/gui/controlspanel.py +++ b/katrain/gui/controlspanel.py @@ -2,11 +2,11 @@ import time from kivy.clock import Clock from kivy.core.audio import SoundLoader -from kivy.properties import ObjectProperty, OptionProperty, NumericProperty +from kivy.properties import NumericProperty, ObjectProperty, OptionProperty from kivy.uix.boxlayout import BoxLayout from kivymd.uix.floatlayout import MDFloatLayout -from katrain.core.constants import MODE_PLAY, MODE_ANALYZE, STATUS_ERROR, STATUS_ANALYSIS, PLAYER_HUMAN +from katrain.core.constants import MODE_ANALYZE, MODE_PLAY, PLAYER_HUMAN, STATUS_ANALYSIS, STATUS_ERROR from katrain.core.lang import rank_label from katrain.gui.kivyutils import AnalysisToggle, CollapsablePanel diff --git a/katrain/gui/kivyutils.py b/katrain/gui/kivyutils.py index 35f641c..c024a74 100644 --- a/katrain/gui/kivyutils.py +++ b/katrain/gui/kivyutils.py @@ -1,7 +1,6 @@ from kivy.clock import Clock from kivy.core.text import Label as CoreLabel from kivy.core.text.markup import MarkupLabel as CoreMarkupLabel - from kivy.core.window import Window from kivy.graphics import * from kivy.properties import ( @@ -12,7 +11,7 @@ from kivy.properties import ( OptionProperty, StringProperty, ) -from kivy.uix.behaviors import ButtonBehavior, ToggleButtonBehavior, FocusBehavior +from kivy.uix.behaviors import ButtonBehavior, FocusBehavior, ToggleButtonBehavior from kivy.uix.boxlayout import BoxLayout from kivy.uix.button import Button from kivy.uix.label import Label diff --git a/katrain/gui/style.py b/katrain/gui/style.py index 7c300df..092d054 100644 --- a/katrain/gui/style.py +++ b/katrain/gui/style.py @@ -16,7 +16,7 @@ GREEN = [0.1, 0.8, 0.1, 1] YELLOW = [0.8, 0.8, 0.1, 1] DARKRED = [0.3, 0.1, 0.1, 1] ORANGE = [242 / 255, 96 / 255, 34 / 255, 1] - +LIGHT_ORANGE = [1, 0.5, 0.25, 1] # gui colors BACKGROUND_COLOR = [36 / 255, 48 / 255, 62 / 255, 1] BOX_BACKGROUND_COLOR = [46 / 255, 65 / 255, 88 / 255, 1] diff --git a/katrain/gui/widgets/__init__.py b/katrain/gui/widgets/__init__.py index f5ccb45..e5bec48 100644 --- a/katrain/gui/widgets/__init__.py +++ b/katrain/gui/widgets/__init__.py @@ -1,6 +1,6 @@ -from katrain.gui.widgets.graph import ScoreGraph, RankGraph -from katrain.gui.widgets.movetree import MoveTree from katrain.gui.widgets.filebrowser import I18NFileBrowser +from katrain.gui.widgets.graph import RankGraph, ScoreGraph +from katrain.gui.widgets.movetree import MoveTree from katrain.gui.widgets.selection_slider import SelectionSlider __all__ = ["ScoreGraph", "RankGraph", "MoveTree", "I18NFileBrowser", "SelectionSlider"] diff --git a/katrain/gui/widgets/movetree.py b/katrain/gui/widgets/movetree.py index e9f1d73..7d90e6b 100644 --- a/katrain/gui/widgets/movetree.py +++ b/katrain/gui/widgets/movetree.py @@ -12,8 +12,12 @@ from kivymd.app import MDApp from katrain.gui.kivyutils import BackgroundMixin, draw_circle, draw_text from katrain.gui.style import ( BACKGROUND_COLOR, + DARKRED, + GREEN, + LIGHT_ORANGE, LIGHTER_BACKGROUND_COLOR, LIGHTGREY, + ORANGE, OUTLINE_COLORS, RED, STONE_COLORS, @@ -106,10 +110,9 @@ class MoveTreeCanvas(Widget): return self.set_game_node(same_x_moves[new_index][1]) - def draw_move_tree(self, current_node): + def draw_move_tree(self, current_node, insert_node): if not self.scroll_view_widget or not current_node: return - spacing = 5 moves_vert = 3 self.move_size = (self.scroll_view_widget.height - (moves_vert + 1) * spacing) / moves_vert @@ -148,6 +151,15 @@ class MoveTreeCanvas(Widget): self.move_xy_pos = {n: xy_pos(x, y) for n, (x, y) in self.move_pos.items()} + special_nodes = {self.menu_selected_node: RED, current_node: YELLOW} + + if insert_node: + special_nodes[insert_node.parent] = GREEN + insert_path = current_node + while insert_path != insert_node.parent and insert_path.parent: + special_nodes[insert_path] = ORANGE if insert_path == current_node else LIGHT_ORANGE + insert_path = insert_path.parent + with self.canvas: self.canvas.clear() Color(*LIGHTGREY) @@ -157,8 +169,8 @@ class MoveTreeCanvas(Widget): Line(points=[x, y, x, cy, cx, cy], width=1) for node, pos in self.move_xy_pos.items(): - if node == self.menu_selected_node or node == current_node: - Color(*(RED if node == self.menu_selected_node else YELLOW)) + if node in special_nodes: + Color(*special_nodes[node]) Rectangle( pos=[c - self.move_size / 2 - spacing / 2 for c in self.move_xy_pos[node]], size=(self.move_size + spacing, self.move_size + spacing), @@ -177,11 +189,15 @@ class MoveTree(ScrollView, BackgroundMixin): def __init__(self, **kwargs): super().__init__(**kwargs) + self.insert_node = None self.redraw_tree_trigger = Clock.create_trigger( - lambda _dt: self.move_tree_canvas.draw_move_tree(self.current_node) + lambda _dt: self.move_tree_canvas.draw_move_tree(self.current_node, self.insert_node) ) self.bind(current_node=self.redraw_tree_trigger, size=self.redraw_tree_trigger) + def redraw(self): + self.redraw_tree_trigger() + def switch_branch(self, direction): self.move_tree_canvas.switch_branch(direction) diff --git a/katrain/i18n/locales/cn/LC_MESSAGES/katrain.mo b/katrain/i18n/locales/cn/LC_MESSAGES/katrain.mo index 0e03668..0b8839b 100644 Binary files a/katrain/i18n/locales/cn/LC_MESSAGES/katrain.mo and b/katrain/i18n/locales/cn/LC_MESSAGES/katrain.mo differ diff --git a/katrain/i18n/locales/cn/LC_MESSAGES/katrain.po b/katrain/i18n/locales/cn/LC_MESSAGES/katrain.po index 4a0dba9..fe94413 100644 --- a/katrain/i18n/locales/cn/LC_MESSAGES/katrain.po +++ b/katrain/i18n/locales/cn/LC_MESSAGES/katrain.po @@ -671,23 +671,6 @@ msgstr "" msgid "Make Main Branch" msgstr "设为实战变化" -#. TODO - DEPRECATED -msgid "aihelp:settle" -msgstr "" -"Plays moves that lead to clarity on stones' status, favouring solid moves " -"rather than complex sabaki. Of moves that lose at most 'max_points_lost' " -"points and with at least 'min_visits', prefer moves that lose fewer points, " -"settle own stones more (with importance settled_weight), settle opponent's " -"stones more (importance settled_weight * opponent_fac), avoid tenuki (more " -"than 5 spaces, importance tenuki_penalty), and avoid attachments (importance" -" attachment_penalty). Weights can be negative to make it complicate the game" -" instead, and wide root noise (in general settings) can be used to further " -"play according to the style at the cost of strength. " - -#. TODO - DEPRECATED -msgid "ai:settle" -msgstr "Settle Style" - #. TODO - setting: what to show on top move (e.g. point loss, visits, ...) msgid "stats on top move" msgstr "Stats on top moves" @@ -742,3 +725,17 @@ msgstr "Save SGF File" # sgf save as button msgid "Save File" msgstr "Save File" + +#. TODO - status message on starting insert mode +msgid "starting insert mode" +msgstr "Starting insert mode, press 'i' to finish inserting." + +#. TODO - status message on ending insert mode and copying the moves +msgid "ending insert mode" +msgstr "Inserting exchange(s) done, copied {num_copied} following moves." + +#. TODO - when a user tries to go to a different move/node while in insert +#. mode +msgid "finish inserting before navigating" +msgstr "" +"Navigation is disabled in insert mode, finish insert mode by pressing 'i'. " diff --git a/katrain/i18n/locales/de/LC_MESSAGES/katrain.mo b/katrain/i18n/locales/de/LC_MESSAGES/katrain.mo index 00a1586..eb73abc 100644 Binary files a/katrain/i18n/locales/de/LC_MESSAGES/katrain.mo and b/katrain/i18n/locales/de/LC_MESSAGES/katrain.mo differ diff --git a/katrain/i18n/locales/de/LC_MESSAGES/katrain.po b/katrain/i18n/locales/de/LC_MESSAGES/katrain.po index 98fa667..a50b06b 100644 --- a/katrain/i18n/locales/de/LC_MESSAGES/katrain.po +++ b/katrain/i18n/locales/de/LC_MESSAGES/katrain.po @@ -707,18 +707,6 @@ msgstr "" msgid "ai:simple" msgstr "Einfacher Stil" -#. TODO - DEPRECATED -msgid "aihelp:settle" -msgstr "" -"Spielt Züge, die dazu zu einer Vereinfachung des Brettzustandes führen. Von " -"Zügen,die höchstens 'max_points_lost' Punkte verlieren und mit wenigstens " -"'min_visits' Visits, bevorzuge die Züge, die weniger Punkte verlieren, " -"eigenes Gebiet mehr sichern" - -#. TODO - DEPRECATED -msgid "ai:settle" -msgstr "Settle Style" - msgid "analysis:local" msgstr "Finde lokale Antworten" @@ -789,3 +777,17 @@ msgstr "Save SGF File" # sgf save as button msgid "Save File" msgstr "Save File" + +#. TODO - status message on starting insert mode +msgid "starting insert mode" +msgstr "Starting insert mode, press 'i' to finish inserting." + +#. TODO - status message on ending insert mode and copying the moves +msgid "ending insert mode" +msgstr "Inserting exchange(s) done, copied {num_copied} following moves." + +#. TODO - when a user tries to go to a different move/node while in insert +#. mode +msgid "finish inserting before navigating" +msgstr "" +"Navigation is disabled in insert mode, finish insert mode by pressing 'i'. " diff --git a/katrain/i18n/locales/en/LC_MESSAGES/katrain.mo b/katrain/i18n/locales/en/LC_MESSAGES/katrain.mo index a8528ea..818091f 100644 Binary files a/katrain/i18n/locales/en/LC_MESSAGES/katrain.mo and b/katrain/i18n/locales/en/LC_MESSAGES/katrain.mo differ diff --git a/katrain/i18n/locales/en/LC_MESSAGES/katrain.po b/katrain/i18n/locales/en/LC_MESSAGES/katrain.po index b244f04..6c3478c 100644 --- a/katrain/i18n/locales/en/LC_MESSAGES/katrain.po +++ b/katrain/i18n/locales/en/LC_MESSAGES/katrain.po @@ -615,23 +615,6 @@ msgstr "" "root noise (in general settings) can be used to increase play according to " "the style at the cost of strength. " -#. DEPRECATED -msgid "ai:settle" -msgstr "Settle Style" - -#. DEPRECATED -msgid "aihelp:settle" -msgstr "" -"Plays moves that lead to clarity on stones' status, favouring solid moves " -"rather than complex sabaki. Of moves that lose at most 'max_points_lost' " -"points and with at least 'min_visits', prefer moves that lose fewer points, " -"settle own stones more (with importance settled_weight), settle opponent's " -"stones more (importance settled_weight * opponent_fac), avoid tenuki (more " -"than 5 spaces, importance tenuki_penalty), and avoid attachments (importance" -" attachment_penalty). Weights can be negative to make it complicate the game" -" instead, and wide root noise (in general settings) can be used to further " -"play according to the style at the cost of strength. " - msgid "ai:jigo" msgstr "KataJigo" @@ -810,3 +793,16 @@ msgstr "---" #. top move stats show threshold description msgid "show stats if" msgstr "Show stats if more than ... visits" + +#. status message on starting insert mode +msgid "starting insert mode" +msgstr "Starting insert mode, press 'i' to finish inserting." + +#. status message on ending insert mode and copying the moves +msgid "ending insert mode" +msgstr "Inserting exchange(s) done, copied {num_copied} following moves." + +#. when a user tries to go to a different move/node while in insert mode +msgid "finish inserting before navigating" +msgstr "" +"Navigation is disabled in insert mode, finish insert mode by pressing 'i'. " diff --git a/katrain/i18n/locales/es/LC_MESSAGES/katrain.mo b/katrain/i18n/locales/es/LC_MESSAGES/katrain.mo index c4bd3c5..2ae865f 100644 Binary files a/katrain/i18n/locales/es/LC_MESSAGES/katrain.mo and b/katrain/i18n/locales/es/LC_MESSAGES/katrain.mo differ diff --git a/katrain/i18n/locales/es/LC_MESSAGES/katrain.po b/katrain/i18n/locales/es/LC_MESSAGES/katrain.po index 6424d3d..454cd9e 100644 --- a/katrain/i18n/locales/es/LC_MESSAGES/katrain.po +++ b/katrain/i18n/locales/es/LC_MESSAGES/katrain.po @@ -713,23 +713,6 @@ msgstr "Plays moves that lead to simplifying the board state." msgid "ai:simple" msgstr "Simple Style" -#. TODO - DEPRECATED -msgid "aihelp:settle" -msgstr "" -"Plays moves that lead to clarity on stones' status, favouring solid moves " -"rather than complex sabaki. Of moves that lose at most 'max_points_lost' " -"points and with at least 'min_visits', prefer moves that lose fewer points, " -"settle own stones more (with importance settled_weight), settle opponent's " -"stones more (importance settled_weight * opponent_fac), avoid tenuki (more " -"than 5 spaces, importance tenuki_penalty), and avoid attachments (importance" -" attachment_penalty). Weights can be negative to make it complicate the game" -" instead, and wide root noise (in general settings) can be used to further " -"play according to the style at the cost of strength. " - -#. TODO - DEPRECATED -msgid "ai:settle" -msgstr "Settle Style" - #. TODO - Analyze again but allow only nearby moves msgid "analysis:local" msgstr "Find local responses" @@ -802,3 +785,17 @@ msgstr "Save SGF File" # sgf save as button msgid "Save File" msgstr "Save File" + +#. TODO - status message on starting insert mode +msgid "starting insert mode" +msgstr "Starting insert mode, press 'i' to finish inserting." + +#. TODO - status message on ending insert mode and copying the moves +msgid "ending insert mode" +msgstr "Inserting exchange(s) done, copied {num_copied} following moves." + +#. TODO - when a user tries to go to a different move/node while in insert +#. mode +msgid "finish inserting before navigating" +msgstr "" +"Navigation is disabled in insert mode, finish insert mode by pressing 'i'. " diff --git a/katrain/i18n/locales/fr/LC_MESSAGES/katrain.mo b/katrain/i18n/locales/fr/LC_MESSAGES/katrain.mo index e51cd5c..7814ed0 100644 Binary files a/katrain/i18n/locales/fr/LC_MESSAGES/katrain.mo and b/katrain/i18n/locales/fr/LC_MESSAGES/katrain.mo differ diff --git a/katrain/i18n/locales/fr/LC_MESSAGES/katrain.po b/katrain/i18n/locales/fr/LC_MESSAGES/katrain.po index 284dc3a..3aefa0d 100644 --- a/katrain/i18n/locales/fr/LC_MESSAGES/katrain.po +++ b/katrain/i18n/locales/fr/LC_MESSAGES/katrain.po @@ -743,23 +743,6 @@ msgstr "" msgid "ai:simple" msgstr "Modéré" -#. TODO - DEPRECATED -msgid "aihelp:settle" -msgstr "" -"Plays moves that lead to clarity on stones' status, favouring solid moves " -"rather than complex sabaki. Of moves that lose at most 'max_points_lost' " -"points and with at least 'min_visits', prefer moves that lose fewer points, " -"settle own stones more (with importance settled_weight), settle opponent's " -"stones more (importance settled_weight * opponent_fac), avoid tenuki (more " -"than 5 spaces, importance tenuki_penalty), and avoid attachments (importance" -" attachment_penalty). Weights can be negative to make it complicate the game" -" instead, and wide root noise (in general settings) can be used to further " -"play according to the style at the cost of strength. " - -#. TODO - DEPRECATED -msgid "ai:settle" -msgstr "Settle Stones Style" - msgid "analysis:local" msgstr "Proposer des coups locaux" @@ -828,3 +811,17 @@ msgstr "Save SGF File" # sgf save as button msgid "Save File" msgstr "Save File" + +#. TODO - status message on starting insert mode +msgid "starting insert mode" +msgstr "Starting insert mode, press 'i' to finish inserting." + +#. TODO - status message on ending insert mode and copying the moves +msgid "ending insert mode" +msgstr "Inserting exchange(s) done, copied {num_copied} following moves." + +#. TODO - when a user tries to go to a different move/node while in insert +#. mode +msgid "finish inserting before navigating" +msgstr "" +"Navigation is disabled in insert mode, finish insert mode by pressing 'i'. " diff --git a/katrain/i18n/locales/jp/LC_MESSAGES/katrain.mo b/katrain/i18n/locales/jp/LC_MESSAGES/katrain.mo index 0f962aa..0b59b07 100644 Binary files a/katrain/i18n/locales/jp/LC_MESSAGES/katrain.mo and b/katrain/i18n/locales/jp/LC_MESSAGES/katrain.mo differ diff --git a/katrain/i18n/locales/jp/LC_MESSAGES/katrain.po b/katrain/i18n/locales/jp/LC_MESSAGES/katrain.po index b97431d..e1d37d3 100644 --- a/katrain/i18n/locales/jp/LC_MESSAGES/katrain.po +++ b/katrain/i18n/locales/jp/LC_MESSAGES/katrain.po @@ -698,18 +698,6 @@ msgstr "" msgid "ai:simple" msgstr "簡明派" -msgid "aihelp:settle" -msgstr "" -"複雑なサバキよりも, 石の生死をはっきりさせる堅実な手を好みます. 具体的には, 次の基準で手を選びます (括弧内は重視度): 損する目数が少ない, " -"自分の生死が明確 (settled_weight), 相手の生死も明確 (settled_weight × opponent fac), " -"相手が打った手の近辺…縦横とも3間以内 (tenuki_penalty), 相手の石に接触しない (attachment_penalty). ただし, " -"損が大きすぎたり (max_points_lost目以上) 探索手数が少なすぎたり (min_visits手未満) する候補手は除きます. " -"重視度を負にすれば, 逆に盤面の複雑化をめざします. また, 一般設定のwide root noiseを大きくすれば, 強さは犠牲になりますが, " -"より前述の基準に忠実な打ち方をします." - -msgid "ai:settle" -msgstr "堅実派" - #. Analyze again but allow only nearby moves msgid "analysis:local" msgstr "近辺の応手に絞って分析" @@ -781,3 +769,17 @@ msgstr "Save SGF File" # sgf save as button msgid "Save File" msgstr "Save File" + +#. TODO - status message on starting insert mode +msgid "starting insert mode" +msgstr "Starting insert mode, press 'i' to finish inserting." + +#. TODO - status message on ending insert mode and copying the moves +msgid "ending insert mode" +msgstr "Inserting exchange done and copied {num_copied} following moves." + +#. TODO - when a user tries to go to a different move/node while in insert +#. mode +msgid "finish inserting before navigating" +msgstr "" +"Navigation is disabled in insert mode, finish insert mode by pressing 'i'. " diff --git a/katrain/i18n/locales/ko/LC_MESSAGES/katrain.mo b/katrain/i18n/locales/ko/LC_MESSAGES/katrain.mo index 0b1bcc4..94a611d 100644 Binary files a/katrain/i18n/locales/ko/LC_MESSAGES/katrain.mo and b/katrain/i18n/locales/ko/LC_MESSAGES/katrain.mo differ diff --git a/katrain/i18n/locales/ko/LC_MESSAGES/katrain.po b/katrain/i18n/locales/ko/LC_MESSAGES/katrain.po index 012114a..3fe3b13 100644 --- a/katrain/i18n/locales/ko/LC_MESSAGES/katrain.po +++ b/katrain/i18n/locales/ko/LC_MESSAGES/katrain.po @@ -682,23 +682,6 @@ msgstr "" "이 판에 대해\n" "덤과 규칙 등 조절" -#. TODO - DEPRECATED -msgid "ai:settle" -msgstr "Settle Style" - -#. TODO - DEPRECATED -msgid "aihelp:settle" -msgstr "" -"Plays moves that lead to clarity on stones' status, favouring solid moves " -"rather than complex sabaki. Of moves that lose at most 'max_points_lost' " -"points and with at least 'min_visits', prefer moves that lose fewer points, " -"settle own stones more (with importance settled_weight), settle opponent's " -"stones more (importance settled_weight * opponent_fac), avoid tenuki (more " -"than 5 spaces, importance tenuki_penalty), and avoid attachments (importance" -" attachment_penalty). Weights can be negative to make it complicate the game" -" instead, and wide root noise (in general settings) can be used to further " -"play according to the style at the cost of strength. " - msgid "Make Main Branch" msgstr "주 변화로 만들기" @@ -756,3 +739,17 @@ msgstr "Save SGF File" # sgf save as button msgid "Save File" msgstr "Save File" + +#. TODO - status message on starting insert mode +msgid "starting insert mode" +msgstr "Starting insert mode, press 'i' to finish inserting." + +#. TODO - status message on ending insert mode and copying the moves +msgid "ending insert mode" +msgstr "Inserting exchange(s) done, copied {num_copied} following moves." + +#. TODO - when a user tries to go to a different move/node while in insert +#. mode +msgid "finish inserting before navigating" +msgstr "" +"Navigation is disabled in insert mode, finish insert mode by pressing 'i'. " diff --git a/katrain/i18n/locales/ru/LC_MESSAGES/katrain.mo b/katrain/i18n/locales/ru/LC_MESSAGES/katrain.mo index f44aec6..38dece2 100644 Binary files a/katrain/i18n/locales/ru/LC_MESSAGES/katrain.mo and b/katrain/i18n/locales/ru/LC_MESSAGES/katrain.mo differ diff --git a/katrain/i18n/locales/ru/LC_MESSAGES/katrain.po b/katrain/i18n/locales/ru/LC_MESSAGES/katrain.po index 1b74dc9..dd19fc8 100644 --- a/katrain/i18n/locales/ru/LC_MESSAGES/katrain.po +++ b/katrain/i18n/locales/ru/LC_MESSAGES/katrain.po @@ -706,22 +706,6 @@ msgstr "" msgid "ai:simple" msgstr "Простой стиль" -msgid "aihelp:settle" -msgstr "" -"Делает ходы, ведущие к ясности в статусе камней, предпочитая надёжные ходы, " -"нежели сложное сабаки. Из ходов, теряющих не более чем 'max_points_lost' " -"очков и имеющих как минимум 'min_visits', предпочитает ходы, укрепляющие " -"собственную территорию (коэффициент settled_weight), укрепляющие территорию " -"оппонента (коэффициент settled_weight * opponent_fac), избегает тэнуки " -"(более 5 пунктов, коэффициент tenuki_penalty), и избегает прилипаний " -"(коэффициент attachment_penalty). Коэффициенты могут быть отрицательными, " -"чтобы напротив сделать игру сложнее. 'Уровень шума' (в 'Настройках системы')" -" может быть использован для увеличения вариативности игры за счёт небольшой " -"потери силы. " - -msgid "ai:settle" -msgstr "Надёжный стиль" - msgid "analysis:local" msgstr "Найти локальные ответы" @@ -790,3 +774,17 @@ msgstr "Save SGF File" # sgf save as button msgid "Save File" msgstr "Save File" + +#. TODO - status message on starting insert mode +msgid "starting insert mode" +msgstr "Starting insert mode, press 'i' to finish inserting." + +#. TODO - status message on ending insert mode and copying the moves +msgid "ending insert mode" +msgstr "Inserting exchange(s) done, copied {num_copied} following moves." + +#. TODO - when a user tries to go to a different move/node while in insert +#. mode +msgid "finish inserting before navigating" +msgstr "" +"Navigation is disabled in insert mode, finish insert mode by pressing 'i'. " diff --git a/requirements.txt b/requirements.txt index 8965eac..67fb1d9 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,4 +1,3 @@ -bson==0.5.10 certifi==2020.6.20 chardet==3.0.4 Cython==0.29.14 diff --git a/setup.py b/setup.py index 2ca7be5..b192bbf 100644 --- a/setup.py +++ b/setup.py @@ -1,5 +1,5 @@ -import re import os +import re from setuptools import find_packages, setup @@ -42,7 +42,6 @@ setup( "wheel", "setuptools", "urllib3", - "bson", "importlib_resources ;python_version<'3.7'", "cython>=0.24,<=0.29.14,!=0.27,!=0.27.2", # kivy wants this "kivy==2.0.0rc2;platform_system=='Darwin'", # rc3 failing on mac diff --git a/tests/test_ai.py b/tests/test_ai.py index e49c366..a0403fb 100644 --- a/tests/test_ai.py +++ b/tests/test_ai.py @@ -1,11 +1,12 @@ -import pytest import os -from katrain.core.ai import generate_ai_move, ai_rank_estimation -from katrain.core.constants import AI_STRATEGIES_RECOMMENDED_ORDER, AI_STRATEGIES, OUTPUT_INFO + +import pytest + +from katrain.core.ai import ai_rank_estimation, generate_ai_move from katrain.core.base_katrain import KaTrainBase +from katrain.core.constants import AI_STRATEGIES, AI_STRATEGIES_RECOMMENDED_ORDER, OUTPUT_INFO from katrain.core.engine import KataGoEngine from katrain.core.game import Game -from katrain.core.constants import AI_STRATEGIES class TestAI: diff --git a/tests/test_board.py b/tests/test_board.py index f177304..15a8361 100644 --- a/tests/test_board.py +++ b/tests/test_board.py @@ -1,7 +1,7 @@ import pytest +from katrain.core.base_katrain import OUTPUT_INFO, KaTrainBase from katrain.core.game import Game, IllegalMoveException, Move -from katrain.core.base_katrain import KaTrainBase, OUTPUT_INFO from katrain.core.game_node import GameNode