Skip to content

Commit ebc286c

Browse files
authored
Hash updates (#151)
* Remove power of 2 recommendation. * Raise runtime error in case hash is somehow set before threads. * formatting
1 parent 66c15e1 commit ebc286c

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ There are some default engine settings used by this wrapper. For increasing Stoc
4646
"Min Split Depth": 0,
4747
"Threads": 1, # More threads will make the engine stronger, but should be kept at less than the number of logical processors on your computer.
4848
"Ponder": False,
49-
"Hash": 16, # Default size is 16 MB. It's recommended that you increase this value, but keep it as some power of 2. E.g., if you're fine using 2 GB of RAM, set Hash to 2048 (11th power of 2).
49+
"Hash": 16, # Default size is 16 MB. It's recommended that you increase this value, to however many MBs of RAM you're willing to allocate (e.g., 2048 for 2GB of RAM).
5050
"MultiPV": 1,
5151
"Skill Level": 20,
5252
"Move Overhead": 10,

stockfish/models.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -307,7 +307,7 @@ def update_engine_parameters(
307307
elif "UCI_Elo" in new_param_values:
308308
new_param_values.update({"UCI_LimitStrength": True})
309309

310-
if "Threads" in new_param_values:
310+
if going_to_set_threads := ("Threads" in new_param_values):
311311
# Recommended to set the hash param after threads.
312312
threads_value = new_param_values["Threads"]
313313
del new_param_values["Threads"]
@@ -321,6 +321,12 @@ def update_engine_parameters(
321321
new_param_values["Hash"] = hash_value
322322

323323
for name, value in new_param_values.items():
324+
if name == "Hash" and going_to_set_threads:
325+
raise RuntimeError(
326+
"Unexpected error - should be setting hash after threads"
327+
)
328+
if name == "Threads":
329+
going_to_set_threads = False
324330
self._set_option(name, value)
325331
self.set_fen_position(self.get_fen_position())
326332
# Getting SF to set the position again, since UCI option(s) have been updated.

0 commit comments

Comments
 (0)