Skip to content

Commit

Permalink
gtp to 52, debug json in json
Browse files Browse the repository at this point in the history
  • Loading branch information
Sander Land committed May 3, 2020
1 parent eef08ed commit de16348
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 9 deletions.
2 changes: 1 addition & 1 deletion core/engine.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ def send_query(self, query, callback, error_callback, next_move=None):
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']}: {str(query)}", OUTPUT_DEBUG)
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()
Expand Down
14 changes: 8 additions & 6 deletions core/sgf_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ class ParseError(Exception):


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"
SGF_COORD = list("ABCDEFGHIJKLMNOPQRSTUVWXYZ".lower()) + list("ABCDEFGHIJKLMNOPQRSTUVWXYZ")

Expand Down Expand Up @@ -212,15 +212,17 @@ def play(self, move) -> "SGFNode":

@property
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 "B"
else:
return "B"

@property
def player(self):
if "W" in self.properties:
return "W"
return "B"
if "B" in self.properties or "AB" in self.properties:
return "B"
else:
return "W" # nb root is considered white played if no handicap stones are placed


class SGF:
Expand Down
3 changes: 1 addition & 2 deletions gui/popups.py
Original file line number Diff line number Diff line change
Expand Up @@ -173,13 +173,12 @@ def restart_engine(_dt):
old_proc = old_engine.katago_process
if old_proc:
old_engine.shutdown(finish=True)

new_engine = KataGoEngine(self.katrain, self.config["engine"])
self.katrain.engine = new_engine
self.katrain.game.engines = {"B": new_engine, "W": new_engine}
if not old_proc:
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)

self.katrain.debug_level = self.config["debug"]["level"]
Expand Down

0 comments on commit de16348

Please sign in to comment.