Skip to content

Commit 11399c6

Browse files
authored
Merge pull request #1178 from johndoknjas/set-hash-after-threads
Ensure hash is always set after threads.
2 parents 0e900e2 + a28315b commit 11399c6

File tree

1 file changed

+10
-6
lines changed

1 file changed

+10
-6
lines changed

chess/engine.py

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1875,12 +1875,16 @@ def _parse_uci_bestmove(board: chess.Board, args: str) -> BestMove:
18751875
return BestMove(move, ponder)
18761876

18771877

1878-
def _chain_config(a: ConfigMapping, b: ConfigMapping) -> Iterator[Tuple[str, ConfigValue]]:
1879-
for name, value in a.items():
1880-
yield name, value
1881-
for name, value in b.items():
1882-
if name not in a:
1883-
yield name, value
1878+
def _chain_config(a: ConfigMapping, b: ConfigMapping) -> Iterable[Tuple[str, ConfigValue]]:
1879+
merged = dict(a)
1880+
for k, v in b.items():
1881+
merged.setdefault(k, v)
1882+
if "Hash" in merged and "Threads" in merged:
1883+
# Move Hash after Threads, as recommended by Stockfish.
1884+
hash_val = merged["Hash"]
1885+
del merged["Hash"]
1886+
merged["Hash"] = hash_val
1887+
return merged.items()
18841888

18851889

18861890
class UciOptionMap(MutableMapping[str, T]):

0 commit comments

Comments
 (0)