This commit is contained in:
Sander Land committed 2020-09-05 10:57:07 +02:00
1 parent 3fd6057f54
commit e9593b6bc6
4 files changed
+54 -25

No files matched your search

+7 -6
View File
@@ -452,7 +452,6 @@ class BadukPanWidget(Widget):
width=dp(1.2),
)
# children of current moves in undo / review
alpha = GHOST_ALPHA
if katrain.analysis_controls.show_children.active:
@@ -465,12 +464,14 @@ class BadukPanWidget(Widget):
(move.coords, [move.gtp()] + child_node.candidate_moves[0]["pv"], current_node)
)
Color(*STONE_COLORS[child_node.player])
for s in range(0,360,30):
for s in range(0, 360, 30):
Line(
circle=(
self.gridpos_x[move.coords[0]],
self.gridpos_y[move.coords[1]],
self.stone_size - 1.2,s,s+15
self.stone_size - 1.2,
s,
s + 12,
),
width=dp(1.2),
)
@@ -520,9 +521,9 @@ class BadukPanWidget(Widget):
stone_size = self.stone_size * sizefac
Color(1, 1, 1, 1)
Rectangle(
pos=(board_coords[0] - stone_size, board_coords[1] - stone_size),
size=(2 * stone_size, 2 * stone_size),
Rectangle( # not sure why the -1 here, but seems to center better
pos=(board_coords[0] - stone_size - 1, board_coords[1] - stone_size),
size=(2 * stone_size + 1, 2 * stone_size + 1),
source=f"img/{move_player}_stone.png",
)
Color(*STONE_TEXT_COLORS[move_player])
+22 -7
View File
@@ -205,7 +205,7 @@ class IMETextField(MDTextField):
self._imo_cursor = self.cursor
class I18NSpinner(Spinner):
class KeyValueSpinner(Spinner):
__events__ = ["on_select"]
sync_height_frac = NumericProperty(1.0)
value_refs = ListProperty()
@@ -214,9 +214,8 @@ class I18NSpinner(Spinner):
def __init__(self, **kwargs):
super().__init__(**kwargs)
self.bind(size=self.update_dropdown_props, pos=self.update_dropdown_props, value_refs=self.i18n_values)
self.i18n_values()
MDApp.get_running_app().bind(language=self.i18n_values)
self.build_values()
self.bind(size=self.update_dropdown_props, pos=self.update_dropdown_props, value_refs=self.build_values)
@property
def selected(self):
@@ -245,9 +244,8 @@ class I18NSpinner(Spinner):
except (ValueError, IndexError):
pass
def i18n_values(self, *_args):
if self.value_refs:
self.values = [i18n._(ref) for ref in self.value_refs]
def build_values(self, *_args):
if self.value_refs and self.values:
self.text = self.values[self.selected_index]
self.font_name = i18n.font_name
self.update_dropdown_props()
@@ -269,6 +267,23 @@ class I18NSpinner(Spinner):
item.font_name = self.font_name
class I18NSpinner(KeyValueSpinner):
__events__ = ["on_select"]
sync_height_frac = NumericProperty(1.0)
value_refs = ListProperty()
selected_index = NumericProperty(0)
font_name = StringProperty(DEFAULT_FONT)
def __init__(self, **kwargs):
super().__init__(**kwargs)
MDApp.get_running_app().bind(language=self.build_values)
def build_values(self, *_args):
self.values = [i18n._(ref) for ref in self.value_refs]
super().build_values()
class PlayerSetup(MDBoxLayout):
player = OptionProperty("B", options=["B", "W"])
mode = StringProperty("")
+22 -8
View File
@@ -412,8 +412,17 @@ class ConfigPopup(QuickConfigGui):
self.model_files.text = models_available_msg
def check_katas(self, *args):
def find_description(path):
file = os.path.split(path)[1].replace(".exe", "")
file_to_desc = {kg.replace(".zip", ""): desc for _, kgs in self.KATAGOS.items() for desc, kg in kgs.items()}
print(file_to_desc,file)
if file in file_to_desc:
return f"{file_to_desc[file]} ({path})"
else:
return f"unkn {path}"
done = set()
model_files = []
kata_files = []
for path in self.katago_paths + [self.katago_path.text]:
path = path.rstrip("/\\")
if path.startswith("katrain"):
@@ -433,11 +442,14 @@ class ConfigPopup(QuickConfigGui):
]
if files and path not in self.paths:
self.paths.append(path) # persistent on paths with models found
model_files += files
katas_available_msg = i18n._("katago binaries available").format(num=len(model_files))
self.katago_files.values = [katas_available_msg, i18n._("default katago option")] + sorted(
model_files, key=lambda f: "bs29" in f
)
kata_files += files
kata_files = [(path, find_description(path)) for path in sorted(kata_files, key=lambda f: "bs29" in f)]
katas_available_msg = i18n._("katago binaries available").format(num=len(kata_files))
self.katago_files.values = [katas_available_msg, i18n._("default katago option")] + [
path for path, desc in kata_files
]
self.katago_files.value_keys = ["", ""] + [desc for path, desc in kata_files]
self.katago_files.text = katas_available_msg
MODELS = {
@@ -449,18 +461,20 @@ class ConfigPopup(QuickConfigGui):
KATAGOS = {
"win": {
"OpenCL v1.6.1": "https://github.com/lightvector/KataGo/releases/download/v1.6.1/katago-v1.6.1-gpu-opencl-windows-x64.zip",
# "CUDA v1.6.1 (New NVIDIA cards)": "https://github.com/lightvector/KataGo/releases/download/v1.6.1/katago-v1.6.1-gpu-cuda10.2-windows-x64.zip",
"Eigen AVX2 (Modern CPUs) v1.6.1": "https://github.com/lightvector/KataGo/releases/download/v1.6.1/katago-v1.6.1-cpu-eigen-avx2-windows-x64.zip",
"Eigen (CPU, Non-optimized) v1.6.1": "https://github.com/lightvector/KataGo/releases/download/v1.6.1/katago-v1.6.1-cpu-eigen-windows-x64.zip",
"OpenCL v1.6.1 (bigger boards)": "https://github.com/lightvector/KataGo/releases/download/v1.6.1%2Bbs29/katago-v1.6.1+bs29-gpu-opencl-windows-x64.zip",
},
"linux": {
"OpenCL v1.6.1": "https://github.com/lightvector/KataGo/releases/download/v1.6.1/katago-v1.6.1-gpu-opencl-linux-x64.zip",
# "CUDA v1.6.1 (New NVIDIA cards)": "https://github.com/lightvector/KataGo/releases/download/v1.6.1/katago-v1.6.1-gpu-cuda10.2-linux-x64.zip",
"Eigen AVX2 (Modern CPUs) v1.6.1": "https://github.com/lightvector/KataGo/releases/download/v1.6.1/katago-v1.6.1-cpu-eigen-avx2-linux-x64.zip",
"Eigen (CPU, Non-optimized) v1.6.1": "https://github.com/lightvector/KataGo/releases/download/v1.6.1/katago-v1.6.1-cpu-eigen-linux-x64.zip",
"OpenCL v1.6.1 (bigger boards)": "https://github.com/lightvector/KataGo/releases/download/v1.6.1%2Bbs29/katago-v1.6.1+bs29-gpu-opencl-linux-x64.zip",
},
"just-descriptions": {
"CUDA v1.6.1 (New NVIDIA cards)": "https://github.com/lightvector/KataGo/releases/download/v1.6.1/katago-v1.6.1-gpu-cuda10.2-windows-x64.zip",
"CUDA v1.6.1 (New NVIDIA cards)": "https://github.com/lightvector/KataGo/releases/download/v1.6.1/katago-v1.6.1-gpu-cuda10.2-linux-x64.zip",
},
}
def download_models(self, *_largs):
+3 -4
View File
@@ -109,12 +109,11 @@
on_press: root.download_katas()
size_hint_y: 0.7
AnchorLayout:
Spinner:
KeyValueSpinner:
id: katago_files
text: ''
on_text:
if self.text and self.text == self.values[1]: katago_path.text = ''
elif self.text and self.text != self.values[0]: katago_path.text = args[1]
on_select:
if self.selected_index != 0: katago_path.text = self.values[self.selected_index]
size_hint_y: 0.7
sync_height_frac: 1.0
-font_size: self.height * 0.5