Skip to content

Commit d59bad5

Browse files
committed
Ensure hash is always set after threads.
1 parent 0e900e2 commit d59bad5

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed

chess/engine.py

Lines changed: 9 additions & 5 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():
1878+
def _chain_config(a: ConfigMapping, b: ConfigMapping, with_hash_reordering: bool = True) -> Iterator[Tuple[str, ConfigValue]]:
1879+
merged = dict(a)
1880+
for k, v in b.items():
1881+
merged.setdefault(k, v)
1882+
if with_hash_reordering and 'Hash' in merged and 'Threads' in merged:
1883+
hash_val = merged['Hash']
1884+
del merged['Hash']
1885+
merged['Hash'] = hash_val
1886+
for name, value in merged.items():
18801887
yield name, value
1881-
for name, value in b.items():
1882-
if name not in a:
1883-
yield name, value
18841888

18851889

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

0 commit comments

Comments
 (0)