Skip to content

Commit

Permalink
Merge pull request #122 from kiudee/send_uci
Browse files Browse the repository at this point in the history
Always pass "uci" as first initString to the engine
  • Loading branch information
kiudee committed Mar 22, 2021
2 parents 91300dc + 976622f commit 61fd745
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
1 change: 1 addition & 0 deletions HISTORY.rst
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ History
* Print user facing scores using the more common Elo scale, instead of negative
downscaled values used internally.
* Internal constants set to improved values.
* Always send ``uci`` first before sending ``setoption`` commands to the engine.

0.7.1 (2020-12-08)
------------------
Expand Down
12 changes: 11 additions & 1 deletion tune/io.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,13 +47,17 @@ def __len__(self):

def __getitem__(self, key):
for s in self._init_strings:
if s == "uci":
continue
name, value = uci_tuple(s)
if key == name:
return value
raise KeyError(key)

def __setitem__(self, key, value):
for i, s in enumerate(self._init_strings):
if s == "uci":
continue
name, _ = uci_tuple(s)
if key == name:
self._init_strings[i] = _set_option(key, value)
Expand All @@ -63,6 +67,8 @@ def __setitem__(self, key, value):
def __delitem__(self, key):
elem = -1
for i, s in enumerate(self._init_strings):
if s == "uci":
continue
name, _ = uci_tuple(s)
if key == name:
elem = i
Expand All @@ -74,13 +80,17 @@ def __delitem__(self, key):

def __contains__(self, key):
for s in self._init_strings:
if s == "uci":
continue
name, _ = uci_tuple(s)
if key == name:
return True
return False

def __iter__(self):
for s in self._init_strings:
if s == "uci":
continue
name, _ = uci_tuple(s)
yield name

Expand Down Expand Up @@ -192,7 +202,7 @@ def load_tuning_config(json_dict):

def prepare_engines_json(commands, fixed_params):
result_list = [
{"command": c, "name": f"engine{i+1}", "initStrings": [], "protocol": "uci"}
{"command": c, "name": f"engine{i+1}", "initStrings": ["uci"], "protocol": "uci"}
for i, c in enumerate(commands)
]
for r, fp in zip(result_list, fixed_params):
Expand Down

0 comments on commit 61fd745

Please sign in to comment.