Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 1 addition & 7 deletions stockfish/types.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ class StockfishParameters:
contempt: int
min_split_depth: int
minimum_thinking_time: int
uci_show_wdl: bool | None = None

def to_dict(self) -> dict[str, str | int | bool]:
mappings: dict[str, str | int | bool | None] = {
Expand All @@ -46,7 +45,6 @@ def to_dict(self) -> dict[str, str | int | bool]:
"Contempt": self.contempt,
"Min Split Depth": self.min_split_depth,
"Minimum Thinking Time": self.minimum_thinking_time,
"UCI_ShowWDL": self.uci_show_wdl,
}
return {k: v for k, v in mappings.items() if v is not None}

Expand All @@ -66,17 +64,13 @@ def update(self, params: dict[str, str | int | bool]) -> None:
"Contempt": "contempt",
"Min Split Depth": "min_split_depth",
"Minimum Thinking Time": "minimum_thinking_time",
"UCI_ShowWDL": "uci_show_wdl",
}

for dict_key, value in params.items():
field_name = mappings.get(dict_key)
if field_name is None:
continue
if (
type(getattr(self, field_name)) is not type(value)
and field_name != "uci_show_wdl"
):
if type(getattr(self, field_name)) is not type(value):
raise ValueError("wrong type")
setattr(self, field_name, value)

Expand Down
1 change: 0 additions & 1 deletion tests/stockfish/test_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -339,7 +339,6 @@ def test_update_engine_parameters_wrong_vals(self, stockfish: Stockfish):
"UCI_LimitStrength": ["true", "false", "False", 1, 0],
"Ponder": ["true", "false", "True", "False", 0],
"Hash": [-1, max_hash * 2, max_hash + 1, -2048, True, 0],
"UCI_ShowWDL": [None, 1, "True"],
"Not key": [0],
}
for name in bad_values:
Expand Down
Loading