Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor and add num_nodes and verbose options to get_top_moves() #16

Merged
merged 39 commits into from
Apr 20, 2023
Merged
Show file tree
Hide file tree
Changes from 32 commits
Commits
Show all changes
39 commits
Select commit Hold shift + click to select a range
8a5ebdc
Add include_info=True flag to .get_top_moves()
knutole Sep 29, 2022
c201434
Update stockfish/models.py
knutole Apr 4, 2023
0906d2e
Update readme with include_info flag
knutole Apr 5, 2023
bb0800d
Refactor get_top_moves():
knutole Apr 7, 2023
53e23e8
Update README. Cleanup.
knutole Apr 7, 2023
0b0eadb
Merge branch 'master' into improve_get_top_moves
knutole Apr 7, 2023
aad00a5
lint with black
knutole Apr 7, 2023
666113f
Rename to is_turn_perspective; cleanup
knutole Apr 7, 2023
cb0750f
Remove unnecessary depth arg
knutole Apr 8, 2023
b81106b
Remove tests for get_top_moves(depth)
knutole Apr 8, 2023
5650fab
Update tests
knutole Apr 8, 2023
29e2f33
Use self._depth as int, add public getter
knutole Apr 8, 2023
48a3725
Add type check for .set_depth(); add tests
knutole Apr 8, 2023
99efaa4
Add type check for .set_num_nodes(); add tests
knutole Apr 8, 2023
aa07dbd
Add type check for .set_is_turn_perspective(); add tests
knutole Apr 8, 2023
8e34653
Add types to new options
knutole Apr 8, 2023
4dc39c2
Use public functions to set depth, num_nodes, is_turn_perspective to …
knutole Apr 8, 2023
1399db7
Fix grammar
knutole Apr 8, 2023
2663e6f
Add tests for instantiating Stockfish class
knutole Apr 8, 2023
c95a88e
Add test coverage for some missing lines
knutole Apr 8, 2023
bf8af50
Cleanup test names
knutole Apr 8, 2023
6513973
Fix minor cosmetic issues
knutole Apr 8, 2023
6b09ab4
Rename is_turn_perspective -> get/set turn_perspective
knutole Apr 8, 2023
29eb5b8
Use update_parameters_attribute of _set_option()
knutole Apr 9, 2023
b7a7fe7
Make use of default arg for _set_option; add tests for _set_option
knutole Apr 9, 2023
61e00e7
Add convenience method _pick()
knutole Apr 10, 2023
61288e9
Split tests
knutole Apr 16, 2023
89690fc
Split tests
knutole Apr 16, 2023
94ad50d
Remove default list in _pick
knutole Apr 16, 2023
ee945dc
Fix typo
knutole Apr 16, 2023
22cc3e3
Fix typo
knutole Apr 16, 2023
996afa2
Fix typo
knutole Apr 16, 2023
8c9e95e
Update text
knutole Apr 16, 2023
45f50ac
Lint
knutole Apr 16, 2023
028e4da
Lint with black
knutole Apr 16, 2023
3fdfec4
Review: update README, parametrize tests
knutole Apr 17, 2023
fcc198a
Fix tests
knutole Apr 17, 2023
a33579d
Remove comments
knutole Apr 17, 2023
e4f261d
Fix minor formatting errors
knutole Apr 17, 2023
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
45 changes: 38 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -135,16 +135,47 @@ True
```

### Get info on the top n moves
Get moves, centipawns, and mates for the top n moves. If the move is a mate, the Centipawn value will be None, and vice versa.

```python
stockfish.get_top_moves(3)
# [
# {'Move': 'f5h7', 'Centipawn': None, 'Mate': 1},
# {'Move': 'f5d7', 'Centipawn': 713, 'Mate': None},
# {'Move': 'f5h5', 'Centipawn': -31, 'Mate': None}
# ]
```
Optional parameter `verbose` (default `False`) specifies whether to include the full info from the engine in the returned dictionary, including SelectiveDepth, Nodes, NodesPerSecond, Time, MultiPVLine, and WDL if available.
```py
stockfish.get_top_moves(1, verbose=True)
# [{
# "Move":"d6e7",
# "Centipawn":-408,
# "Mate":"None",
# "Nodes":"2767506",
# "NodesPerSecond":"526442",
# "Time":"5257",
# "SelectiveDepth":"31",
# "MultiPVLine":"1",
# "WDL":"0 0 1000"
# }]
```
Optional parameter `num_nodes` specifies the number of nodes to search. If num_nodes is 0, then the engine will search until it configured depth is reached.
knutole marked this conversation as resolved.
Show resolved Hide resolved

### Set perspective of the evaluation
knutole marked this conversation as resolved.
Show resolved Hide resolved
You can set the perspective of the evaluation to be from the perspective of the side to move, or from the perspective of White.
```py
# Set the perspective of the evaluation to be from the point of view of the side to move
stockfish.set_turn_perspective(True)

# Set the perspective of the evaluation to be from White's perspective
stockfish.set_turn_perspective(False)

# Get the current perspective of the evaluation
is_turn_perspective = stockfish.get_turn_perspective()

```
```text
[
{'Move': 'f5h7', 'Centipawn': None, 'Mate': 1},
{'Move': 'f5d7', 'Centipawn': 713, 'Mate': None},
{'Move': 'f5h5', 'Centipawn': -31, 'Mate': None}
]
```


### Get Stockfish's win/draw/loss stats for the side to move in the current position
Before calling this function, it is recommended that you first check if your version of Stockfish is recent enough to display WDL stats. To do this,
Expand Down
Loading