gtp to 52, debug json in json

This commit is contained in:
Sander Land committed 2020-05-03 19:46:58 +02:00
1 parent eef08ed96e
commit de16348084
3 files changed
+10 -9

No files matched your search

+1 -1
View File
@@ -113,7 +113,7 @@ class KataGoEngine:
query["id"] = f"QUERY:{str(self.query_counter)}" query["id"] = f"QUERY:{str(self.query_counter)}"
self.queries[query["id"]] = (callback, error_callback, time.time(), next_move) self.queries[query["id"]] = (callback, error_callback, time.time(), next_move)
if self.katago_process: if self.katago_process:
self.katrain.log(f"Sending query {query['id']}: {str(query)}", OUTPUT_DEBUG) self.katrain.log(f"Sending query {query['id']}: {json.dumps(query)}", OUTPUT_DEBUG)
try: try:
self.katago_process.stdin.write((json.dumps(query) + "\n").encode()) self.katago_process.stdin.write((json.dumps(query) + "\n").encode())
self.katago_process.stdin.flush() self.katago_process.stdin.flush()
+8 -6
View File
@@ -9,7 +9,7 @@ class ParseError(Exception):
class Move: class Move:
GTP_COORD = list("ABCDEFGHJKLMNOPQRSTUVWXYZ") + ["A" + c for c in "ABCDEFGHJKLMNOPQRSTUVWXYZ"] # kata board size 29 support GTP_COORD = list("ABCDEFGHJKLMNOPQRSTUVWXYZ") + [xa + c for xa in "AB" for c in "ABCDEFGHJKLMNOPQRSTUVWXYZ"] # kata board size 29 support
PLAYERS = "BW" PLAYERS = "BW"
SGF_COORD = list("ABCDEFGHIJKLMNOPQRSTUVWXYZ".lower()) + list("ABCDEFGHIJKLMNOPQRSTUVWXYZ") SGF_COORD = list("ABCDEFGHIJKLMNOPQRSTUVWXYZ".lower()) + list("ABCDEFGHIJKLMNOPQRSTUVWXYZ")
@@ -212,15 +212,17 @@ class SGFNode:
@property @property
def next_player(self): def next_player(self):
if "B" in self.properties or "AB" in self.properties: if "B" in self.properties or "AB" in self.properties: # root or black moved
return "W" return "W"
return "B" else:
return "B"
@property @property
def player(self): def player(self):
if "W" in self.properties: if "B" in self.properties or "AB" in self.properties:
return "W" return "B"
return "B" else:
return "W" # nb root is considered white played if no handicap stones are placed
class SGF: class SGF:
+1 -2
View File
@@ -173,13 +173,12 @@ class ConfigPopup(QuickConfigGui):
old_proc = old_engine.katago_process old_proc = old_engine.katago_process
if old_proc: if old_proc:
old_engine.shutdown(finish=True) old_engine.shutdown(finish=True)
new_engine = KataGoEngine(self.katrain, self.config["engine"]) new_engine = KataGoEngine(self.katrain, self.config["engine"])
self.katrain.engine = new_engine self.katrain.engine = new_engine
self.katrain.game.engines = {"B": new_engine, "W": new_engine} self.katrain.game.engines = {"B": new_engine, "W": new_engine}
if not old_proc: if not old_proc:
self.katrain.game.analyze_all_nodes() # old engine was broken, so make sure we redo any failures self.katrain.game.analyze_all_nodes() # old engine was broken, so make sure we redo any failures
self.katrain.update_state()
Clock.schedule_once(restart_engine, 0) Clock.schedule_once(restart_engine, 0)
self.katrain.debug_level = self.config["debug"]["level"] self.katrain.debug_level = self.config["debug"]["level"]