Spaces:
Sleeping
Sleeping
Yohaan Seth Nathan commited on
Commit ·
cdae82e
1
Parent(s): 1cd60f7
Set USI_Variant directly in engine communication file (#117)
Browse files- config.yml.default +1 -1
- engine_ctrl/usi.py +9 -1
- engine_wrapper.py +1 -3
config.yml.default
CHANGED
|
@@ -22,7 +22,7 @@ engine: # Engine Settings.
|
|
| 22 |
usi_options: # Arbitrary USI options passed to the engine.
|
| 23 |
# Move Overhead: 500 # Increase if your bot flags games too often.
|
| 24 |
Threads: 1 # Max CPU threads the engine can use.
|
| 25 |
-
#
|
| 26 |
# go_commands: # Additional options to pass to the USI go command.
|
| 27 |
# nodes: 1 # Search so many nodes only.
|
| 28 |
# depth: 5 # Search depth ply only.
|
|
|
|
| 22 |
usi_options: # Arbitrary USI options passed to the engine.
|
| 23 |
# Move Overhead: 500 # Increase if your bot flags games too often.
|
| 24 |
Threads: 1 # Max CPU threads the engine can use.
|
| 25 |
+
# USI_Hash: 256 # Max memory (in megabytes) the engine can allocate.
|
| 26 |
# go_commands: # Additional options to pass to the USI go command.
|
| 27 |
# nodes: 1 # Search so many nodes only.
|
| 28 |
# depth: 5 # Search depth ply only.
|
engine_ctrl/usi.py
CHANGED
|
@@ -8,9 +8,10 @@ logger = logging.getLogger(__name__)
|
|
| 8 |
|
| 9 |
|
| 10 |
class Engine:
|
| 11 |
-
def __init__(self, command, cwd=None):
|
| 12 |
self.info = {}
|
| 13 |
self.id = {}
|
|
|
|
| 14 |
cwd = cwd or os.path.realpath(os.path.expanduser("."))
|
| 15 |
self.proccess = self.open_process(command, cwd)
|
| 16 |
self.go_commands = None
|
|
@@ -124,6 +125,13 @@ class Engine:
|
|
| 124 |
|
| 125 |
self.send("setoption name %s value %s" % (name, value))
|
| 126 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 127 |
def go(self, position, moves, movetime=None, btime=None, wtime=None, binc=None, winc=None, byo=None, depth=None, nodes=None, ponder=False):
|
| 128 |
self.position(position, moves)
|
| 129 |
|
|
|
|
| 8 |
|
| 9 |
|
| 10 |
class Engine:
|
| 11 |
+
def __init__(self, variants, command, cwd=None):
|
| 12 |
self.info = {}
|
| 13 |
self.id = {}
|
| 14 |
+
self.variants = variants
|
| 15 |
cwd = cwd or os.path.realpath(os.path.expanduser("."))
|
| 16 |
self.proccess = self.open_process(command, cwd)
|
| 17 |
self.go_commands = None
|
|
|
|
| 125 |
|
| 126 |
self.send("setoption name %s value %s" % (name, value))
|
| 127 |
|
| 128 |
+
def set_variant_options(self, variant):
|
| 129 |
+
variant = variant.lower()
|
| 130 |
+
if variant in ["standard"]:
|
| 131 |
+
self.setoption("USI_Variant", "shogi")
|
| 132 |
+
else:
|
| 133 |
+
self.setoption("USI_Variant", variant)
|
| 134 |
+
|
| 135 |
def go(self, position, moves, movetime=None, btime=None, wtime=None, binc=None, winc=None, byo=None, depth=None, nodes=None, ponder=False):
|
| 136 |
self.position(position, moves)
|
| 137 |
|
engine_wrapper.py
CHANGED
|
@@ -9,15 +9,13 @@ from engine_ctrl import usi
|
|
| 9 |
|
| 10 |
|
| 11 |
@backoff.on_exception(backoff.expo, BaseException, max_time=120)
|
| 12 |
-
def create_engine(config
|
| 13 |
cfg = config["engine"]
|
| 14 |
engine_path = os.path.realpath(os.path.join(cfg["dir"], cfg["name"]))
|
| 15 |
engine_working_dir = cfg.get("working_dir") or os.getcwd()
|
| 16 |
engine_type = cfg.get("protocol")
|
| 17 |
engine_options = cfg.get("engine_options")
|
| 18 |
usi_options = cfg.get("usi_options") or {}
|
| 19 |
-
if variant != "Standard":
|
| 20 |
-
usi_options["USI_Variant"] = variant.lower()
|
| 21 |
commands = [engine_path]
|
| 22 |
if engine_options:
|
| 23 |
for k, v in engine_options.items():
|
|
|
|
| 9 |
|
| 10 |
|
| 11 |
@backoff.on_exception(backoff.expo, BaseException, max_time=120)
|
| 12 |
+
def create_engine(config):
|
| 13 |
cfg = config["engine"]
|
| 14 |
engine_path = os.path.realpath(os.path.join(cfg["dir"], cfg["name"]))
|
| 15 |
engine_working_dir = cfg.get("working_dir") or os.getcwd()
|
| 16 |
engine_type = cfg.get("protocol")
|
| 17 |
engine_options = cfg.get("engine_options")
|
| 18 |
usi_options = cfg.get("usi_options") or {}
|
|
|
|
|
|
|
| 19 |
commands = [engine_path]
|
| 20 |
if engine_options:
|
| 21 |
for k, v in engine_options.items():
|