Skip to content

Commit 4385da5

Browse files
authored
Revise docstrings (#173)
* Remove `UCI_ShowWDL` as a user-facing parameter. * Remove parentheses. * Revise some docstrings so that the popups in vscode are formatted nicer. * Format with ruff.
1 parent 6f42fa6 commit 4385da5

File tree

1 file changed

+36
-63
lines changed

1 file changed

+36
-63
lines changed

stockfish/models.py

Lines changed: 36 additions & 63 deletions
Original file line numberDiff line numberDiff line change
@@ -144,11 +144,7 @@ def set_debug_view(self, activate: bool) -> None:
144144
self._debug_view = activate
145145

146146
def get_engine_parameters(self) -> dict[str, str | int | bool]:
147-
"""Returns the current engine parameters being used.
148-
149-
Returns:
150-
A deep copy of the dictionary storing the current engine parameters.
151-
"""
147+
"""Returns a deep copy of the dictionary storing the current engine parameters."""
152148
return self._parameters.to_dict()
153149

154150
def get_parameters(self):
@@ -344,9 +340,6 @@ def set_fen_position(self, fen_position: str) -> None:
344340
fen_position:
345341
FEN string of board position.
346342
347-
Returns:
348-
`None`
349-
350343
Example:
351344
>>> stockfish.set_fen_position("1nb1k1n1/pppppppp/8/6r1/5bqK/6r1/8/8 w - - 2 2")
352345
"""
@@ -405,29 +398,30 @@ def get_board_visual(self, perspective_white: bool = True) -> str:
405398
perspective of white. `True` indicates White's perspective.
406399
407400
Returns:
408-
A visual representation of the chessboard in the current position.
409-
410-
For example:
411-
```
412-
+---+---+---+---+---+---+---+---+
413-
| r | n | b | q | k | b | n | r | 8
414-
+---+---+---+---+---+---+---+---+
415-
| p | p | p | p | p | p | p | p | 7
416-
+---+---+---+---+---+---+---+---+
417-
| | | | | | | | | 6
418-
+---+---+---+---+---+---+---+---+
419-
| | | | | | | | | 5
420-
+---+---+---+---+---+---+---+---+
421-
| | | | | | | | | 4
422-
+---+---+---+---+---+---+---+---+
423-
| | | | | | | | | 3
424-
+---+---+---+---+---+---+---+---+
425-
| P | P | P | P | P | P | P | P | 2
426-
+---+---+---+---+---+---+---+---+
427-
| R | N | B | Q | K | B | N | R | 1
428-
+---+---+---+---+---+---+---+---+
429-
a b c d e f g h
430-
```
401+
str:
402+
A visual representation of the chessboard in the current position.
403+
404+
For example:
405+
```
406+
+---+---+---+---+---+---+---+---+
407+
| r | n | b | q | k | b | n | r | 8
408+
+---+---+---+---+---+---+---+---+
409+
| p | p | p | p | p | p | p | p | 7
410+
+---+---+---+---+---+---+---+---+
411+
| | | | | | | | | 6
412+
+---+---+---+---+---+---+---+---+
413+
| | | | | | | | | 5
414+
+---+---+---+---+---+---+---+---+
415+
| | | | | | | | | 4
416+
+---+---+---+---+---+---+---+---+
417+
| | | | | | | | | 3
418+
+---+---+---+---+---+---+---+---+
419+
| P | P | P | P | P | P | P | P | 2
420+
+---+---+---+---+---+---+---+---+
421+
| R | N | B | Q | K | B | N | R | 1
422+
+---+---+---+---+---+---+---+---+
423+
a b c d e f g h
424+
```
431425
"""
432426
self._put("d")
433427
board_rep_lines: list[str] = []
@@ -461,11 +455,9 @@ def get_board_visual(self, perspective_white: bool = True) -> str:
461455
return board_rep
462456

463457
def get_fen_position(self) -> str:
464-
"""Returns the current board position in Forsyth-Edwards notation (FEN).
465-
466-
Returns:
467-
A string of the current board position in Forsyth-Edwards notation (FEN).
468-
For example: `rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR w KQkq - 0 1`
458+
"""
459+
Returns a string of the current board position in Forsyth-Edwards notation (FEN).
460+
For example: `rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR w KQkq - 0 1`
469461
"""
470462
self._put("d")
471463
while True:
@@ -577,17 +569,13 @@ def get_turn_perspective(self) -> bool:
577569
def get_best_move(
578570
self, wtime: int | None = None, btime: int | None = None
579571
) -> str | None:
580-
"""Returns the best move in the current position on the board.
572+
"""Returns a string of the best move in pure algebraic coordinate notation, or None if it's a mate now.
573+
581574
If both `wtime` and `btime` aren't provided, the current depth is used for the search.
582575
583-
Args:
584-
wtime:
585-
Time for white player in milliseconds.
586-
btime:
587-
Time for black player in milliseconds.
576+
`wtime`: Time for white player in milliseconds.
588577
589-
Returns:
590-
A string of the best move in pure algebraic coordinate notation, or `None` if it's a mate now.
578+
`btime`: Time for black player in milliseconds.
591579
592580
Example:
593581
>>> move = stockfish.get_best_move(wtime=1000, btime=1000)
@@ -599,14 +587,7 @@ def get_best_move(
599587
return self._get_best_move_from_sf_popen_process()
600588

601589
def get_best_move_time(self, time: int = 1000) -> str | None:
602-
"""Returns the best move in the current position after a determined time.
603-
604-
Args:
605-
time:
606-
Time for Stockfish to determine the best move (milliseconds).
607-
608-
Returns:
609-
A string of a move in pure algebraic coordinate notation, or `None` if it's a mate now.
590+
"""Returns a string of the best move in the current position after a determined search time (milliseconds).
610591
611592
Example:
612593
>>> move = stockfish.get_best_move_time(1000)
@@ -676,10 +657,7 @@ def _is_fen_syntax_valid(fen: str) -> bool:
676657
return True
677658

678659
def is_fen_valid(self, fen: str) -> bool:
679-
"""Checks if the FEN string is valid.
680-
681-
Returns:
682-
`True` if valid, `False` otherwise.
660+
"""Returns whether the FEN string is (likely) valid.
683661
684662
Example:
685663
>>> is_valid = stockfish.is_fen_valid("rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR w KQkq - 0 1")
@@ -707,14 +685,9 @@ def is_fen_valid(self, fen: str) -> bool:
707685
# temp_sf object goes out of scope, but calling it explicitly guarantees this will happen.
708686

709687
def is_move_correct(self, move_value: str) -> bool:
710-
"""Checks if the passed in move is legal.
688+
"""Returns if the passed in move is legal.
711689
712-
Args:
713-
move_value:
714-
New move value in pure algebraic coordinate notation.
715-
716-
Returns:
717-
`True` if the new move is legal, otherwise `False`.
690+
`move_value`: new move value in pure algebraic coordinate notation.
718691
719692
Example:
720693
>>> is_correct = stockfish.is_move_correct("f4f5")

0 commit comments

Comments
 (0)