From 95a42188701405ce15b77ae80832c670e307fbb9 Mon Sep 17 00:00:00 2001 From: InigoGutierrez Date: Tue, 13 Sep 2022 16:16:08 +0200 Subject: Configuring nvim LSP. --- imago/engine/core.py | 3 ++- imago/engine/imagoIO.py | 14 ++++++++++---- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/imago/engine/core.py b/imago/engine/core.py index 2bf7d5a..47c8f16 100644 --- a/imago/engine/core.py +++ b/imago/engine/core.py @@ -8,10 +8,11 @@ DEF_SIZE = 9 DEF_KOMI = 5.5 DEF_ALGORITHM = DecisionAlgorithms.KERAS + class GameEngine: """Plays the game of Go.""" - def __init__(self, decisionAlgorithmId = DEF_ALGORITHM): + def __init__(self, decisionAlgorithmId=DEF_ALGORITHM): self.komi = DEF_KOMI self.gameState = GameState(DEF_SIZE) self.daId = decisionAlgorithmId diff --git a/imago/engine/imagoIO.py b/imago/engine/imagoIO.py index 9b3e367..9a89095 100644 --- a/imago/engine/imagoIO.py +++ b/imago/engine/imagoIO.py @@ -5,36 +5,43 @@ import sys from imago.engine import parseHelpers from imago.engine.core import GameEngine + def _response(text=""): print("= %s" % text) print() + def _responseError(text=""): print("? %s" % text) print() + def protocol_version(_): """Version of the GTP Protocol""" _response("2") + def name(_): """Name of the engine""" _response("Imago") + def version(_): """Version of the engine""" _response("0.0.0") + def getCoordsText(row, col): """Returns a string representation of row and col. In GTP A1 is bottom left corner. """ - return "%s%d" % (chr(65+row), col+1) + return "%s%d" % (chr(65 + row), col + 1) + class ImagoIO: """Recieves and handles commands.""" - def __init__(self, decisionAlgorithmId = None): + def __init__(self, decisionAlgorithmId=None): self.commands_set = { protocol_version, name, @@ -72,7 +79,6 @@ class ImagoIO: if command is not None: arguments = input_tokens[1:] - #print("[DEBUG]:Selected command: %s; args: %s" % (command, arguments)) command(arguments) else: _responseError("unknown command") @@ -169,7 +175,7 @@ class ImagoIO: return color = parseHelpers.parseColor(args[0]) output = parseHelpers.vertexToString(self.gameEngine.genmove(color), - self.gameEngine.gameState.size) + self.gameEngine.gameState.size) _response(output) self.gameEngine.gameState.getBoard().printBoard() -- cgit v1.2.1