timer fix

This commit is contained in:
Sander Land committed 2020-05-31 23:01:15 +02:00
1 parent 6bfbd45789
commit d35abfea34
8 files changed
+16 -9

No files matched your search

+1 -1
View File
@@ -57,7 +57,7 @@ def ai_move(game: Game, ai_mode: str, ai_settings: Dict) -> Tuple[Move, GameNode
ai_thoughts += f"Using policy based strategy, base top 5 moves are {fmt_moves(policy_moves[:5])}. "
if ai_mode == AI_POLICY and cn.depth <= ai_settings["opening_moves"]:
ai_mode = AI_WEIGHTED
ai_thoughts += f"Switching to weighted strategy in the opening {int(ai_settings['opening_moves'] * (game.board_size[0]*game.board_size[1]))} moves. "
ai_thoughts += f"Switching to weighted strategy in the opening {int(ai_settings['opening_moves'])} moves. "
ai_settings = {"pick_override": 0.9, "weaken_fac": 1, "lower_bound": 0.02}
if top_5_pass:
aimove = top_policy_move
+4 -2
View File
@@ -27,13 +27,15 @@ def evaluation_class(points_lost: float, eval_thresholds: List[float]):
return i
def find_package_resource(path):
def find_package_resource(path,silent_errors=False):
if path.startswith("katrain"):
parts = path.replace("\\", "/").split("/")
try:
with pkg_resources.path(".".join(parts[:-1]), parts[-1]) as path_obj:
return str(path_obj) # this will clean up if egg etc, but these don't work anyway
except (ModuleNotFoundError, FileNotFoundError) as e:
except (ModuleNotFoundError, FileNotFoundError, ValueError) as e:
if silent_errors:
return None
print(f"File {path} not found, installation possibly broken", file=sys.stderr)
return f"FILENOTFOUND::{path}"
else:
+1 -1
View File
@@ -306,7 +306,7 @@ class BadukPanWidget(Widget):
# ownership - allow one move out of date for smooth animation
ownership = current_node.ownership or (current_node.parent and current_node.parent.ownership)
if katrain.analysis_controls.ownership.active and ownership:
if katrain.analysis_controls.ownership.active and ownership and not lock_ai:
ownership_grid = var_to_grid(ownership, (board_size_x, board_size_y))
rsz = self.grid_size * 0.2
for y in range(board_size_y - 1, -1, -1):
+7 -3
View File
@@ -78,7 +78,8 @@ class ControlsPanel(BoxLayout):
elif both_players_are_robots and not current_node.analysis_ready and current_node.parent:
self.active_comment_node = current_node.parent
hints = katrain.analysis_controls.hints.active
lock_ai = katrain.config("trainer/lock_ai") and katrain.play_analyze_mode == MODE_PLAY
hints = katrain.analysis_controls.hints.active and not lock_ai
info = ""
if current_node.move and not current_node.is_root:
info = self.active_comment_node.comment(
@@ -110,7 +111,7 @@ class ControlsPanel(BoxLayout):
byo_num = max(1, self.katrain.config("timer/byo_periods"))
player = self.katrain.next_player_info
ai = player.ai
if not self.timer.paused and not ai:
if not self.timer.paused and not ai and self.katrain.play_analyze_mode == MODE_PLAY:
if last_update_node == current_node and not current_node.children:
current_node.time_used += now - last_update_time
else:
@@ -120,6 +121,9 @@ class ControlsPanel(BoxLayout):
current_node.time_used -= byo_len
time_remaining += byo_len
player.periods_used += 1
time_remaining = byo_len - current_node.time_used
if player.periods_used == byo_num:
time_remaining = 0
else:
time_remaining = byo_len - current_node.time_used
periods_rem = byo_num - player.periods_used
self.timer.state = (max(0, time_remaining), max(0, periods_rem), ai)
+2 -1
View File
@@ -47,7 +47,8 @@ class LabelledPathInput(LabelledTextInput):
Clock.schedule_once(self.check_error, 0)
def check_error(self, _dt=None):
self.error = not os.path.exists(find_package_resource(self.input_value))
file = find_package_resource(self.input_value, silent_errors=True)
self.error = not (file and os.path.exists(file))
def on_text(self, widget, text):
self.check_error()
Binary file not shown.
@@ -161,7 +161,7 @@ msgid "btn:Analysis"
msgstr "Analysis"
msgid "btn:Analyze"
msgstr "Analyze"
msgstr "Analysis Options"
msgid "stats:winrate"
msgstr "Win Rate"
Binary file not shown.