Implement basic cmdline UI framework

Issue #1
This commit is contained in:
2021-12-12 12:50:02 +01:00
parent 6d433a6d01
commit aa899740c6
2 changed files with 29 additions and 4 deletions

View File

@@ -33,7 +33,10 @@ def make_piece(piece_str):
def get_state():
engine.stdin.write(b"get_state\n")
engine.stdin.flush()
position_str = engine.stdout.readline().decode("ascii").strip()
reply = engine.stdout.readline().decode("ascii").strip()
status, position_str = reply.split(",")
if status != "ok":
flask.abort(400)
position = {
position_str[i + 2 : i + 4]: make_piece(position_str[i : i + 2])
for i in range(0, len(position_str), 4)