double click fix & show tuning
This commit is contained in:
1 parent
69f8b60dff
commit
5fc3ce2dc0
5 files changed
+25
-6
No files matched your search
@@ -1,6 +1,7 @@
|
|||||||
from typing import Any, List, Tuple
|
from typing import Any, List, Tuple
|
||||||
|
|
||||||
OUTPUT_ERROR = -1
|
OUTPUT_ERROR = -1
|
||||||
|
OUTPUT_KATAGO_STDERR = -0.5
|
||||||
OUTPUT_INFO = 0
|
OUTPUT_INFO = 0
|
||||||
OUTPUT_DEBUG = 1
|
OUTPUT_DEBUG = 1
|
||||||
OUTPUT_EXTRA_DEBUG = 2
|
OUTPUT_EXTRA_DEBUG = 2
|
||||||
|
|||||||
+12
-2
@@ -6,7 +6,7 @@ import threading
|
|||||||
import time
|
import time
|
||||||
from typing import Callable, Optional
|
from typing import Callable, Optional
|
||||||
|
|
||||||
from core.common import OUTPUT_DEBUG, OUTPUT_ERROR, OUTPUT_EXTRA_DEBUG
|
from core.common import OUTPUT_DEBUG, OUTPUT_ERROR, OUTPUT_EXTRA_DEBUG, OUTPUT_KATAGO_STDERR
|
||||||
from core.game_node import GameNode
|
from core.game_node import GameNode
|
||||||
|
|
||||||
|
|
||||||
@@ -38,11 +38,12 @@ class KataGoEngine:
|
|||||||
self._lock = threading.Lock()
|
self._lock = threading.Lock()
|
||||||
self.start()
|
self.start()
|
||||||
self.analysis_thread = threading.Thread(target=self._analysis_read_thread, daemon=True).start()
|
self.analysis_thread = threading.Thread(target=self._analysis_read_thread, daemon=True).start()
|
||||||
|
self.stderr_thread = threading.Thread(target=self._read_stderr_thread, daemon=True).start()
|
||||||
|
|
||||||
def start(self):
|
def start(self):
|
||||||
try:
|
try:
|
||||||
self.katrain.log(f"Starting KataGo with {self.command}", OUTPUT_DEBUG)
|
self.katrain.log(f"Starting KataGo with {self.command}", OUTPUT_DEBUG)
|
||||||
self.katago_process = subprocess.Popen(self.command, stdin=subprocess.PIPE, stdout=subprocess.PIPE)
|
self.katago_process = subprocess.Popen(self.command, stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
|
||||||
except FileNotFoundError as e:
|
except FileNotFoundError as e:
|
||||||
self.katrain.log(
|
self.katrain.log(
|
||||||
f"Starting kata with command '{self.command}' failed with error {e}. Please make sure the 'katago' value under 'engine' in settings points to the correct KataGo executable.",
|
f"Starting kata with command '{self.command}' failed with error {e}. Please make sure the 'katago' value under 'engine' in settings points to the correct KataGo executable.",
|
||||||
@@ -70,6 +71,15 @@ class KataGoEngine:
|
|||||||
def is_idle(self):
|
def is_idle(self):
|
||||||
return not self.queries
|
return not self.queries
|
||||||
|
|
||||||
|
def _read_stderr_thread(self):
|
||||||
|
while self.katago_process is not None:
|
||||||
|
try:
|
||||||
|
line = self.katago_process.stderr.readline()
|
||||||
|
if line:
|
||||||
|
self.katrain.log(line.decode(), OUTPUT_KATAGO_STDERR)
|
||||||
|
except:
|
||||||
|
return
|
||||||
|
|
||||||
def _analysis_read_thread(self):
|
def _analysis_read_thread(self):
|
||||||
while self.katago_process is not None:
|
while self.katago_process is not None:
|
||||||
try:
|
try:
|
||||||
|
|||||||
+1
-1
@@ -28,7 +28,7 @@ class Move:
|
|||||||
"""Initialize a move from SGF coordinates and player"""
|
"""Initialize a move from SGF coordinates and player"""
|
||||||
if sgf_coords == "" or Move.SGF_COORD.index(sgf_coords[0]) == board_size[0]: # some servers use [tt] for pass
|
if sgf_coords == "" or Move.SGF_COORD.index(sgf_coords[0]) == board_size[0]: # some servers use [tt] for pass
|
||||||
return cls(coords=None, player=player)
|
return cls(coords=None, player=player)
|
||||||
return cls(coords=(Move.SGF_COORD.index(sgf_coords[0]), board_size[1] - Move.SGF_COORD.index(sgf_coords[1]) - 1), player=player,)
|
return cls(coords=(Move.SGF_COORD.index(sgf_coords[0]), board_size[1] - Move.SGF_COORD.index(sgf_coords[1]) - 1), player=player)
|
||||||
|
|
||||||
def __init__(self, coords: Optional[Tuple[int, int]] = None, player: str = "B"):
|
def __init__(self, coords: Optional[Tuple[int, int]] = None, player: str = "B"):
|
||||||
"""Initialize a move from zero-based coordinates and player"""
|
"""Initialize a move from zero-based coordinates and player"""
|
||||||
|
|||||||
+1
-1
@@ -85,7 +85,7 @@ class BadukPanWidget(Widget):
|
|||||||
if nodes_here and max(yd, xd) < self.grid_size / 2: # load old comment
|
if nodes_here and max(yd, xd) < self.grid_size / 2: # load old comment
|
||||||
if touch.is_double_tap: # navigate to move
|
if touch.is_double_tap: # navigate to move
|
||||||
katrain.game.set_current_node(nodes_here[-1])
|
katrain.game.set_current_node(nodes_here[-1])
|
||||||
self.draw_board_contents()
|
katrain.update_state()
|
||||||
else: # load comments
|
else: # load comments
|
||||||
katrain.log(f"\nAnalysis:\n{nodes_here[-1].analysis}", OUTPUT_DEBUG)
|
katrain.log(f"\nAnalysis:\n{nodes_here[-1].analysis}", OUTPUT_DEBUG)
|
||||||
katrain.log(f"\nParent Analysis:\n{nodes_here[-1].parent.analysis}", OUTPUT_DEBUG)
|
katrain.log(f"\nParent Analysis:\n{nodes_here[-1].parent.analysis}", OUTPUT_DEBUG)
|
||||||
|
|||||||
+10
-2
@@ -17,7 +17,7 @@ from kivy.storage.jsonstore import JsonStore
|
|||||||
from kivy.uix.popup import Popup
|
from kivy.uix.popup import Popup
|
||||||
|
|
||||||
from core.ai import ai_move
|
from core.ai import ai_move
|
||||||
from core.common import OUTPUT_INFO, OUTPUT_ERROR, OUTPUT_DEBUG, OUTPUT_EXTRA_DEBUG
|
from core.common import OUTPUT_INFO, OUTPUT_ERROR, OUTPUT_DEBUG, OUTPUT_EXTRA_DEBUG, OUTPUT_KATAGO_STDERR
|
||||||
from core.engine import KataGoEngine
|
from core.engine import KataGoEngine
|
||||||
from core.game import Game, IllegalMoveException, KaTrainSGF
|
from core.game import Game, IllegalMoveException, KaTrainSGF
|
||||||
from core.sgf_parser import Move, ParseError
|
from core.sgf_parser import Move, ParseError
|
||||||
@@ -47,7 +47,15 @@ class KaTrainGui(BoxLayout):
|
|||||||
self._keyboard.bind(on_key_down=self._on_keyboard_down)
|
self._keyboard.bind(on_key_down=self._on_keyboard_down)
|
||||||
|
|
||||||
def log(self, message, level=OUTPUT_INFO):
|
def log(self, message, level=OUTPUT_INFO):
|
||||||
if level == OUTPUT_ERROR:
|
if level == OUTPUT_KATAGO_STDERR:
|
||||||
|
if "starting" in message.lower():
|
||||||
|
self.controls.set_status(f"KataGo engine starting...")
|
||||||
|
if message.startswith("Tuning"):
|
||||||
|
self.controls.set_status(f"KataGo is tuning settings for first startup, please wait." + message)
|
||||||
|
if "ready" in message.lower():
|
||||||
|
self.controls.set_status(f"KataGo engine ready.")
|
||||||
|
print(f"[KG:STDERR]{message}")
|
||||||
|
elif level == OUTPUT_ERROR:
|
||||||
self.controls.set_status(f"ERROR: {message}")
|
self.controls.set_status(f"ERROR: {message}")
|
||||||
print(f"ERROR: {message}")
|
print(f"ERROR: {message}")
|
||||||
elif self.debug_level >= level:
|
elif self.debug_level >= level:
|
||||||
|
|||||||
Reference in new issue
Block a user