kata win new
This commit is contained in:
1 parent
6b7204b355
commit
219513cb43
22 files changed
+110
-101
No files matched your search
@@ -60,7 +60,7 @@ numSearchThreads = 6
|
||||
# GPU Settings-------------------------------------------------------------------------------
|
||||
|
||||
# Maximum number of positions to send to GPU at once.
|
||||
nnMaxBatchSize = 64
|
||||
nnMaxBatchSize = 72
|
||||
# Cache up to 2 ** this many neural net evaluations in case of transpositions in the tree.
|
||||
nnCacheSizePowerOfTwo = 19
|
||||
# Size of mutex pool for nnCache is 2 ** this
|
||||
|
||||
Binary file not shown.
+7
-9
@@ -1,9 +1,10 @@
|
||||
import os # isort:skip
|
||||
from katrain.core.utils import find_package_resource # isort:skip
|
||||
|
||||
os.environ["KCFG_KIVY_LOG_LEVEL"] = os.environ.get("KCFG_KIVY_LOG_LEVEL", "warning") # isort:skip surpress info output
|
||||
from kivy.config import Config # isort:skip
|
||||
|
||||
ICON = "img/icon.ico" # isort:skip # set icon
|
||||
ICON = find_package_resource("katrain/img/icon.ico") # isort:skip # find icon
|
||||
Config.set("kivy", "window_icon", ICON) # isort:skip # set icon
|
||||
Config.set("input", "mouse", "mouse,multitouch_on_demand") # isort:skip # no red dots on right click
|
||||
Config.set("graphics", "width", 1300) # isort:skip
|
||||
@@ -23,10 +24,8 @@ from kivy.resources import resource_add_path
|
||||
from kivy.uix.popup import Popup
|
||||
from kivy.uix.screenmanager import Screen
|
||||
from katrain.core.ai import ai_move
|
||||
from katrain.core.utils import (
|
||||
DEFAULT_LANGUAGE,
|
||||
find_package_resource,
|
||||
)
|
||||
|
||||
from katrain.core.lang import DEFAULT_LANGUAGE, i18n
|
||||
from katrain.core.constants import (
|
||||
OUTPUT_ERROR,
|
||||
OUTPUT_KATAGO_STDERR,
|
||||
@@ -44,12 +43,12 @@ from katrain.core.engine import KataGoEngine
|
||||
from katrain.core.game import Game, IllegalMoveException, KaTrainSGF
|
||||
from katrain.core.sgf_parser import Move, ParseError
|
||||
from katrain.gui.kivyutils import *
|
||||
from katrain.gui.popups import ConfigPopup, LoadSGFPopup, NewGamePopup, AIPopup
|
||||
from katrain.gui.style import ENGINE_BUSY_COL, ENGINE_DOWN_COL, ENGINE_READY_COL
|
||||
from katrain.gui.widgets.graph import ScoreGraph
|
||||
from katrain.gui.widgets.filebrowser import I18NFileBrowser
|
||||
from katrain.gui.badukpan import AnalysisControls, BadukPanControls, BadukPanWidget
|
||||
from katrain.gui.controlspanel import ControlsPanel
|
||||
from katrain.gui.popups import ConfigPopup, LoadSGFPopup, NewGamePopup, AIPopup
|
||||
from katrain.gui.style import ENGINE_BUSY_COL, ENGINE_DOWN_COL, ENGINE_READY_COL
|
||||
|
||||
|
||||
class KaTrainGui(Screen, KaTrainBase):
|
||||
@@ -422,11 +421,10 @@ class KaTrainApp(MDApp):
|
||||
def on_language(self, _instance, language):
|
||||
self.gui.log(f"Switching language to {language}", OUTPUT_INFO)
|
||||
i18n.switch_lang(language)
|
||||
if language!="haha":
|
||||
if language != "haha":
|
||||
self.gui._config["general"]["lang"] = language
|
||||
self.gui.save_config()
|
||||
|
||||
|
||||
def webbrowser(self, site_key):
|
||||
WEBSITES = {"homepage": HOMEPAGE, "support": HOMEPAGE + "#support"}
|
||||
if site_key in WEBSITES:
|
||||
|
||||
+1
-1
@@ -4,7 +4,7 @@
|
||||
"_hint_katago": "Path to your katago executable",
|
||||
"model": "katrain/models/g170e-b15c192-s1672170752-d466197061.bin.gz",
|
||||
"config": "katrain/KataGo/analysis_config.cfg",
|
||||
"threads": 16,
|
||||
"threads": 12,
|
||||
"max_visits": 750,
|
||||
"fast_visits": 50,
|
||||
"max_time": 3.0,
|
||||
|
||||
@@ -7,7 +7,8 @@ import threading
|
||||
import time
|
||||
from typing import Callable, Optional
|
||||
from kivy.utils import platform
|
||||
from katrain.core.utils import find_package_resource, i18n
|
||||
from katrain.core.utils import find_package_resource
|
||||
from katrain.core.lang import i18n
|
||||
from katrain.core.constants import OUTPUT_ERROR, OUTPUT_KATAGO_STDERR, OUTPUT_DEBUG, OUTPUT_EXTRA_DEBUG
|
||||
from katrain.core.game_node import GameNode
|
||||
|
||||
|
||||
@@ -5,7 +5,8 @@ import threading
|
||||
from datetime import datetime
|
||||
from typing import Dict, List, Union, Optional
|
||||
|
||||
from katrain.core.utils import var_to_grid, i18n
|
||||
from katrain.core.utils import var_to_grid
|
||||
from katrain.core.lang import i18n
|
||||
from katrain.core.constants import OUTPUT_INFO, OUTPUT_DEBUG, HOMEPAGE
|
||||
from katrain.core.engine import KataGoEngine
|
||||
from katrain.core.game_node import GameNode
|
||||
|
||||
@@ -2,7 +2,8 @@ import copy
|
||||
import random
|
||||
from typing import Dict, List, Optional, Tuple
|
||||
|
||||
from katrain.core.utils import evaluation_class, var_to_grid, i18n
|
||||
from katrain.core.utils import evaluation_class, var_to_grid
|
||||
from katrain.core.lang import i18n
|
||||
from katrain.core.sgf_parser import Move, SGFNode
|
||||
from katrain.gui.style import INFO_PV_COLOR
|
||||
|
||||
|
||||
@@ -0,0 +1,81 @@
|
||||
import gettext
|
||||
import os
|
||||
import sys
|
||||
from typing import Callable
|
||||
|
||||
from kivy._event import Observable
|
||||
|
||||
from katrain.core.utils import find_package_resource
|
||||
from katrain.gui.style import DEFAULT_FONT
|
||||
|
||||
|
||||
class Lang(Observable):
|
||||
observers = []
|
||||
callbacks = []
|
||||
FONTS = {"ko": "fonts/NotoSansKR-Regular.otf", "haha": "fonts/NotoSansKR-Regular.otf"}
|
||||
|
||||
def __init__(self, lang):
|
||||
super(Lang, self).__init__()
|
||||
self.lang = None
|
||||
self.switch_lang(lang)
|
||||
|
||||
def _(self, text):
|
||||
return self.ugettext(text)
|
||||
|
||||
def set_widget_font(self, widget):
|
||||
widget.font_name = self.font_name
|
||||
for sub_widget in [getattr(widget, "_hint_lbl", None), getattr(widget, "_msg_lbl", None)]: # MDText
|
||||
if sub_widget:
|
||||
sub_widget.font_name = self.font_name
|
||||
|
||||
def fbind(self, name, func, *args):
|
||||
if name == "_":
|
||||
widget, property, *_ = args[0]
|
||||
self.observers.append((widget, func, args))
|
||||
try:
|
||||
self.set_widget_font(widget)
|
||||
except Exception as e:
|
||||
print(e)
|
||||
# pass
|
||||
else:
|
||||
return super(Lang, self).fbind(name, func, *args)
|
||||
|
||||
def funbind(self, name, func, *args):
|
||||
if name == "_":
|
||||
widget, *_ = args[0]
|
||||
key = (widget, func, args)
|
||||
if key in self.observers:
|
||||
self.observers.remove(key)
|
||||
else:
|
||||
return super(Lang, self).funbind(name, func, *args)
|
||||
|
||||
def add_callback(self, callback_fn: Callable): # TODO refactor w app
|
||||
self.callbacks.append(callback_fn)
|
||||
|
||||
def switch_lang(self, lang):
|
||||
if lang == self.lang:
|
||||
return
|
||||
# get the right locales directory, and instantiate a gettext
|
||||
self.lang = lang
|
||||
self.font_name = self.FONTS.get(lang) or DEFAULT_FONT
|
||||
i18n_dir, _ = os.path.split(find_package_resource("katrain/i18n/__init__.py"))
|
||||
locale_dir = os.path.join(i18n_dir, "locales")
|
||||
locales = gettext.translation("katrain", locale_dir, languages=[lang])
|
||||
self.ugettext = locales.gettext
|
||||
|
||||
# update all the kv rules attached to this text
|
||||
for widget, func, args in self.observers:
|
||||
try:
|
||||
func(args[0], None, None)
|
||||
self.set_widget_font(widget)
|
||||
except ReferenceError:
|
||||
pass # proxy no longer exists
|
||||
for cb in self.callbacks:
|
||||
try:
|
||||
cb(self)
|
||||
except Exception as e:
|
||||
print(f"Failed callback on language change: {e}", file=sys.stderr)
|
||||
|
||||
|
||||
DEFAULT_LANGUAGE = "en"
|
||||
i18n = Lang(DEFAULT_LANGUAGE)
|
||||
+1
-78
@@ -1,11 +1,6 @@
|
||||
import os
|
||||
import sys
|
||||
from numbers import Number
|
||||
from typing import List, Tuple, Callable, TypeVar
|
||||
from kivy.lang import Observable
|
||||
import gettext
|
||||
|
||||
from katrain.gui.style import DEFAULT_FONT
|
||||
from typing import List, Tuple, TypeVar
|
||||
|
||||
try:
|
||||
import importlib.resources as pkg_resources
|
||||
@@ -43,75 +38,3 @@ def find_package_resource(path):
|
||||
return f"FILENOTFOUND::{path}"
|
||||
else:
|
||||
return os.path.abspath(os.path.expanduser(path)) # absolute path
|
||||
|
||||
|
||||
class Lang(Observable):
|
||||
observers = []
|
||||
callbacks = []
|
||||
FONTS = {"ko": "fonts/NotoSansKR-Regular.otf", "haha": "fonts/NotoSansKR-Regular.otf"}
|
||||
|
||||
def __init__(self, lang):
|
||||
super(Lang, self).__init__()
|
||||
self.lang = None
|
||||
self.switch_lang(lang)
|
||||
|
||||
def _(self, text):
|
||||
return self.ugettext(text)
|
||||
|
||||
def set_widget_font(self, widget):
|
||||
widget.font_name = self.font_name
|
||||
for sub_widget in [getattr(widget, "_hint_lbl", None), getattr(widget, "_msg_lbl", None)]: # MDText
|
||||
if sub_widget:
|
||||
sub_widget.font_name = self.font_name
|
||||
|
||||
def fbind(self, name, func, *args):
|
||||
if name == "_":
|
||||
widget, property, *_ = args[0]
|
||||
self.observers.append((widget, func, args))
|
||||
try:
|
||||
self.set_widget_font(widget)
|
||||
except Exception as e:
|
||||
print(e)
|
||||
# pass
|
||||
else:
|
||||
return super(Lang, self).fbind(name, func, *args)
|
||||
|
||||
def funbind(self, name, func, *args):
|
||||
if name == "_":
|
||||
widget, *_ = args[0]
|
||||
key = (widget, func, args)
|
||||
if key in self.observers:
|
||||
self.observers.remove(key)
|
||||
else:
|
||||
return super(Lang, self).funbind(name, func, *args)
|
||||
|
||||
def add_callback(self, callback_fn: Callable): # TODO refactor w app
|
||||
self.callbacks.append(callback_fn)
|
||||
|
||||
def switch_lang(self, lang):
|
||||
if lang == self.lang:
|
||||
return
|
||||
# get the right locales directory, and instantiate a gettext
|
||||
self.lang = lang
|
||||
self.font_name = self.FONTS.get(lang) or DEFAULT_FONT
|
||||
i18n_dir, _ = os.path.split(find_package_resource("katrain/i18n/__init__.py"))
|
||||
locale_dir = os.path.join(i18n_dir, "locales")
|
||||
locales = gettext.translation("katrain", locale_dir, languages=[lang])
|
||||
self.ugettext = locales.gettext
|
||||
|
||||
# update all the kv rules attached to this text
|
||||
for widget, func, args in self.observers:
|
||||
try:
|
||||
func(args[0], None, None)
|
||||
self.set_widget_font(widget)
|
||||
except ReferenceError:
|
||||
pass # proxy no longer exists
|
||||
for cb in self.callbacks:
|
||||
try:
|
||||
cb(self)
|
||||
except Exception as e:
|
||||
print(f"Failed callback on language change: {e}", file=sys.stderr)
|
||||
|
||||
|
||||
DEFAULT_LANGUAGE = "en"
|
||||
i18n = Lang(DEFAULT_LANGUAGE)
|
||||
+1
-1
@@ -1,5 +1,5 @@
|
||||
#:kivy 1.11.0
|
||||
#:import i18n katrain.core.utils.i18n
|
||||
#:import i18n katrain.core.lang.i18n
|
||||
|
||||
# TODO: refactor
|
||||
#:set CP_SPACING 6
|
||||
|
||||
@@ -15,7 +15,8 @@ from kivymd.uix.boxlayout import MDBoxLayout
|
||||
from kivymd.uix.floatlayout import MDFloatLayout
|
||||
from kivymd.uix.menu import MDDropdownMenu, RightContent
|
||||
|
||||
from katrain.core.utils import evaluation_class, i18n
|
||||
from katrain.core.utils import evaluation_class
|
||||
from katrain.core.lang import i18n
|
||||
from katrain.core.constants import OUTPUT_DEBUG, MODE_PLAY
|
||||
from katrain.core.game import Move
|
||||
from katrain.gui.kivyutils import draw_circle, draw_text
|
||||
|
||||
@@ -7,7 +7,7 @@ from kivy.uix.popup import Popup
|
||||
from kivymd.uix.boxlayout import MDBoxLayout
|
||||
from kivymd.uix.floatlayout import MDFloatLayout
|
||||
|
||||
from katrain.core.utils import i18n
|
||||
from katrain.core.lang import i18n
|
||||
from katrain.core.constants import MODE_PLAY, MODE_ANALYZE
|
||||
|
||||
|
||||
|
||||
@@ -35,7 +35,7 @@ from kivymd.uix.navigationdrawer import MDNavigationDrawer
|
||||
from kivy.core.text import Label as CoreLabel
|
||||
|
||||
from katrain.core.constants import GAME_TYPES, AI_STRATEGIES_RECOMMENDED_ORDER, PLAYER_HUMAN, PLAYER_AI
|
||||
from katrain.core.utils import i18n
|
||||
from katrain.core.lang import i18n
|
||||
|
||||
#
|
||||
|
||||
|
||||
@@ -21,7 +21,8 @@ from katrain.core.constants import (
|
||||
AI_STRATEGIES_RECOMMENDED_ORDER,
|
||||
)
|
||||
from katrain.core.engine import KataGoEngine
|
||||
from katrain.core.utils import i18n, find_package_resource
|
||||
from katrain.core.utils import find_package_resource
|
||||
from katrain.core.lang import i18n
|
||||
from katrain.gui.kivyutils import I18NSpinner, BackgroundMixin
|
||||
from katrain.gui.style import DEFAULT_FONT, EVAL_COLORS
|
||||
|
||||
|
||||
@@ -162,7 +162,7 @@ Builder.load_string(
|
||||
"""
|
||||
#:import metrics kivy.metrics
|
||||
#:import abspath os.path.abspath
|
||||
#:import i18n katrain.core.utils.i18n
|
||||
#:import i18n katrain.core.lang.i18n
|
||||
|
||||
<Button>:
|
||||
track_lang: i18n._('')
|
||||
|
||||
Binary file not shown.
@@ -329,7 +329,7 @@ msgstr ""
|
||||
|
||||
msgid "lock ai when playing"
|
||||
msgstr ""
|
||||
"Disable analysis\n"
|
||||
"Disable top moves\n"
|
||||
" while in play mode"
|
||||
|
||||
#. submit button
|
||||
|
||||
Binary file not shown.
@@ -324,7 +324,9 @@ msgstr ""
|
||||
"평가를 색으로 표시"
|
||||
|
||||
msgid "lock ai when playing"
|
||||
msgstr "대국 중에 분석하지 않기"
|
||||
msgstr ""
|
||||
"대국 중에\n"
|
||||
"후보수 분석하지 않기"
|
||||
|
||||
#. submit button
|
||||
msgid "update teacher"
|
||||
|
||||
Whitespace-only changes.
Binary file not shown.
|
Before Width: | Height: | Size: 132 KiB After Width: | Height: | Size: 120 KiB |
+1
-1
@@ -1,5 +1,5 @@
|
||||
#:kivy 1.11.0
|
||||
#:import i18n katrain.core.utils.i18n
|
||||
#:import i18n katrain.core.lang.i18n
|
||||
#:import expanduser os.path.expanduser
|
||||
#:import abspath os.path.abspath
|
||||
|
||||
|
||||
Reference in new issue
Block a user