From 353d291ef578c314ae805644531ca06f67a604b3 Mon Sep 17 00:00:00 2001 From: Sander Land Date: Mon, 7 Dec 2020 14:30:51 +0100 Subject: [PATCH] no status/lock engine/no thread --- katrain/core/engine.py | 14 +++++++------- katrain/core/game.py | 5 +---- .../i18n/locales/cn/LC_MESSAGES/katrain.po | 5 ----- .../i18n/locales/de/LC_MESSAGES/katrain.po | 5 ----- .../i18n/locales/en/LC_MESSAGES/katrain.mo | Bin 15645 -> 15533 bytes .../i18n/locales/en/LC_MESSAGES/katrain.po | 6 ------ .../i18n/locales/es/LC_MESSAGES/katrain.po | 5 ----- .../i18n/locales/fr/LC_MESSAGES/katrain.po | 6 ------ .../i18n/locales/jp/LC_MESSAGES/katrain.po | 6 ------ .../i18n/locales/ko/LC_MESSAGES/katrain.po | 5 ----- .../i18n/locales/ru/LC_MESSAGES/katrain.po | 5 ----- 11 files changed, 8 insertions(+), 54 deletions(-) diff --git a/katrain/core/engine.py b/katrain/core/engine.py index d3c1a9e..3934539 100644 --- a/katrain/core/engine.py +++ b/katrain/core/engine.py @@ -228,13 +228,13 @@ class KataGoEngine: if "id" not in query: query["id"] = f"QUERY:{str(self.query_counter)}" self.queries[query["id"]] = (callback, error_callback, time.time(), next_move) - if self.katago_process: - self.katrain.log(f"Sending query {query['id']}: {json.dumps(query)}", OUTPUT_DEBUG) - try: - self.katago_process.stdin.write((json.dumps(query) + "\n").encode()) - self.katago_process.stdin.flush() - except OSError as e: - self.check_alive(os_error=str(e), exception_if_dead=True) + if self.katago_process: + self.katrain.log(f"Sending query {query['id']}: {json.dumps(query)}", OUTPUT_DEBUG) + try: + self.katago_process.stdin.write((json.dumps(query) + "\n").encode()) + self.katago_process.stdin.flush() + except OSError as e: + self.check_alive(os_error=str(e), exception_if_dead=True) def terminate_query(self, query_id): if query_id is not None: diff --git a/katrain/core/game.py b/katrain/core/game.py index ceab62f..078c7a3 100644 --- a/katrain/core/game.py +++ b/katrain/core/game.py @@ -550,7 +550,6 @@ class Game: if move.is_pass: if self.current_node == cn: self.set_current_node(node) - self.katrain.controls.set_status("", STATUS_INFO, cn) return count += 1 new_node = GameNode(parent=node, move=move) @@ -559,8 +558,6 @@ class Game: cn.add_shortcut(new_node) self.katrain.controls.move_tree.redraw_tree_trigger() - self.katrain.controls.set_status(i18n._("playtoend:status").format(num_moves=count), STATUS_INFO, cn) - def set_analysis(result, _partial): new_node.set_analysis(result) analyze_and_play_policy(new_node) @@ -569,7 +566,7 @@ class Game: new_node, callback=set_analysis, priority=-1000, analyze_fast=True, ) - threading.Thread(target=analyze_and_play_policy, args=(cn,), daemon=True).start() + analyze_and_play_policy(cn) def analyze_undo(self, node): train_config = self.katrain.config("trainer") diff --git a/katrain/i18n/locales/cn/LC_MESSAGES/katrain.po b/katrain/i18n/locales/cn/LC_MESSAGES/katrain.po index 842ae99..03e3ce5 100644 --- a/katrain/i18n/locales/cn/LC_MESSAGES/katrain.po +++ b/katrain/i18n/locales/cn/LC_MESSAGES/katrain.po @@ -762,8 +762,3 @@ msgstr "Expand/Collapse" msgid "analysis:playtoend" msgstr "Fast playout to game end" -#. TODO - Status message -msgid "playtoend:status" -msgstr "" -"Playing game to the end with policy strategy, please wait ... {num_moves} " -"moves played." diff --git a/katrain/i18n/locales/de/LC_MESSAGES/katrain.po b/katrain/i18n/locales/de/LC_MESSAGES/katrain.po index 1f56f40..1b83019 100644 --- a/katrain/i18n/locales/de/LC_MESSAGES/katrain.po +++ b/katrain/i18n/locales/de/LC_MESSAGES/katrain.po @@ -814,8 +814,3 @@ msgstr "Expand/Collapse" msgid "analysis:playtoend" msgstr "Fast playout to game end" -#. TODO - Status message -msgid "playtoend:status" -msgstr "" -"Playing the game quickly to the end, please wait ... {num_moves} moves " -"played." diff --git a/katrain/i18n/locales/en/LC_MESSAGES/katrain.mo b/katrain/i18n/locales/en/LC_MESSAGES/katrain.mo index b13f739d4ba8cc5895a3b3901e3c2ca8cfa1eab0..b21422bafb28e696957b881452457134de5ee46c 100644 GIT binary patch delta 3544 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z6L@jUtRq~_Q4=>?DY}4B}-(5t57-l&t&`wlouc7|B-9;V61KfgP z{A%do`~+3f1E?JzK~?S)s$y4A3H*tQcNaB3u#azEXJp(p{b?xRaMVLI5;bu=R^be+ z$H2a{u>oswhVfW~I;y`=J8Q-e40(z&V=q)c9r-adg_wfx zpelF~^|swY#qTkU^XJ&i@L|4z*OB8j3vGWZD&QA59FHN#Y98S;IN)htlbeno$`Cuo*xsC=vz1u^$Ru*6|exc zGZ(esa%_uh(I4MKC02n`a0hn5o2WzrIX7L8L5|Wj18L~SX{a5)j7lWaH^I!ue)Qi* z?fi%xKaF|~?;yu)qLO^i!erF_>8N=5sKghcD!2;yIWXm|a{lXS=;7Ij+Sv)zYjOsa z*acMSenkatu;X`70q2~EQA=`>!Y(GCkx3l^bD z z?EE=S@!TwDPDWmq^F~Sb?3`S$Q(VwG#`HL+FgGisD9c%pkzMR~JRWCpeo5ZUyn;8g Uib|bUn33Vl%Jfvbi5|cI0B;R^mH+?% diff --git a/katrain/i18n/locales/en/LC_MESSAGES/katrain.po b/katrain/i18n/locales/en/LC_MESSAGES/katrain.po index 935d239..40971e8 100644 --- a/katrain/i18n/locales/en/LC_MESSAGES/katrain.po +++ b/katrain/i18n/locales/en/LC_MESSAGES/katrain.po @@ -122,12 +122,6 @@ msgstr "" msgid "analysis:playtoend" msgstr "Fast playout to game end" -#. Status message -msgid "playtoend:status" -msgstr "" -"Playing the game quickly to the end, please wait ... {num_moves} moves " -"played." - #. Keep improving current position analysis when there is nothing else to do msgid "analysis:continuous" msgstr "Toggle continuous analysis" diff --git a/katrain/i18n/locales/es/LC_MESSAGES/katrain.po b/katrain/i18n/locales/es/LC_MESSAGES/katrain.po index c3bc833..c7fdd84 100644 --- a/katrain/i18n/locales/es/LC_MESSAGES/katrain.po +++ b/katrain/i18n/locales/es/LC_MESSAGES/katrain.po @@ -821,8 +821,3 @@ msgstr "Expand/Collapse" msgid "analysis:playtoend" msgstr "Fast playout to game end" -#. TODO - Status message -msgid "playtoend:status" -msgstr "" -"Playing the game quickly to the end, please wait ... {num_moves} moves " -"played." diff --git a/katrain/i18n/locales/fr/LC_MESSAGES/katrain.po b/katrain/i18n/locales/fr/LC_MESSAGES/katrain.po index e65855d..d0f5097 100644 --- a/katrain/i18n/locales/fr/LC_MESSAGES/katrain.po +++ b/katrain/i18n/locales/fr/LC_MESSAGES/katrain.po @@ -847,9 +847,3 @@ msgstr "Expand/Collapse" #. TODO - Menu option msgid "analysis:playtoend" msgstr "Fast playout to game end" - -#. TODO - Status message -msgid "playtoend:status" -msgstr "" -"Playing the game quickly to the end, please wait ... {num_moves} moves " -"played." diff --git a/katrain/i18n/locales/jp/LC_MESSAGES/katrain.po b/katrain/i18n/locales/jp/LC_MESSAGES/katrain.po index b0e571a..bc164b3 100644 --- a/katrain/i18n/locales/jp/LC_MESSAGES/katrain.po +++ b/katrain/i18n/locales/jp/LC_MESSAGES/katrain.po @@ -804,9 +804,3 @@ msgstr "Expand/Collapse" #. TODO - Menu option msgid "analysis:playtoend" msgstr "Fast playout to game end" - -#. TODO - Status message -msgid "playtoend:status" -msgstr "" -"Playing the game quickly to the end, please wait ... {num_moves} moved " -"played.moves played." diff --git a/katrain/i18n/locales/ko/LC_MESSAGES/katrain.po b/katrain/i18n/locales/ko/LC_MESSAGES/katrain.po index e309685..b96207c 100644 --- a/katrain/i18n/locales/ko/LC_MESSAGES/katrain.po +++ b/katrain/i18n/locales/ko/LC_MESSAGES/katrain.po @@ -775,8 +775,3 @@ msgstr "Expand/Collapse" msgid "analysis:playtoend" msgstr "Fast playout to game end" -#. TODO - Status message -msgid "playtoend:status" -msgstr "" -"Playing the game quickly to the end, please wait ... {num_moves} moves " -"played." diff --git a/katrain/i18n/locales/ru/LC_MESSAGES/katrain.po b/katrain/i18n/locales/ru/LC_MESSAGES/katrain.po index 4d6d839..41d000d 100644 --- a/katrain/i18n/locales/ru/LC_MESSAGES/katrain.po +++ b/katrain/i18n/locales/ru/LC_MESSAGES/katrain.po @@ -811,8 +811,3 @@ msgstr "Expand/Collapse" msgid "analysis:playtoend" msgstr "Fast playout to game end" -#. TODO - Status message -msgid "playtoend:status" -msgstr "" -"Playing the game quickly to the end, please wait ... {num_moves} moves " -"played."