@@ -1810,11 +1810,13 @@ def ply(self) -> int:
1810
1810
return 2 * (self .fullmove_number - 1 ) + (self .turn == BLACK )
1811
1811
1812
1812
def remove_piece_at (self , square : Square ) -> Optional [Piece ]:
1813
+ """Remove a piece, if any, from the given square and return the removed piece."""
1813
1814
piece = super ().remove_piece_at (square )
1814
1815
self .clear_stack ()
1815
1816
return piece
1816
1817
1817
1818
def set_piece_at (self , square : Square , piece : Optional [Piece ], promoted : bool = False ) -> None :
1819
+ """Place a piece on a square."""
1818
1820
super ().set_piece_at (square , piece , promoted = promoted )
1819
1821
self .clear_stack ()
1820
1822
@@ -1998,6 +2000,7 @@ def is_pseudo_legal(self, move: Move) -> bool:
1998
2000
return bool (self .attacks_mask (move .from_square ) & to_mask )
1999
2001
2000
2002
def is_legal (self , move : Move ) -> bool :
2003
+ """Check if a move is legal in the current position."""
2001
2004
return not self .is_variant_end () and self .is_pseudo_legal (move ) and not self .is_into_check (move )
2002
2005
2003
2006
def is_variant_end (self ) -> bool :
@@ -2034,9 +2037,27 @@ def is_variant_draw(self) -> bool:
2034
2037
return False
2035
2038
2036
2039
def is_game_over (self , * , claim_draw : bool = False ) -> bool :
2040
+ """
2041
+ Check if the game is over by any rule.
2042
+
2043
+ The game is not considered to be over by the
2044
+ :func:`fifty-move rule <chess.Board.can_claim_fifty_moves()>` or
2045
+ :func:`threefold repetition <chess.Board.can_claim_threefold_repetition()>`,
2046
+ unless *claim_draw* is given. Note that checking the latter can be
2047
+ slow.
2048
+ """
2037
2049
return self .outcome (claim_draw = claim_draw ) is not None
2038
2050
2039
2051
def result (self , * , claim_draw : bool = False ) -> str :
2052
+ """
2053
+ Return the result of a game: 1-0, 0-1, 1/2-1/2, or *.
2054
+
2055
+ The game is not considered to be over by the
2056
+ :func:`fifty-move rule <chess.Board.can_claim_fifty_moves()>` or
2057
+ :func:`threefold repetition <chess.Board.can_claim_threefold_repetition()>`,
2058
+ unless *claim_draw* is given. Note that checking the latter can be
2059
+ slow.
2060
+ """
2040
2061
outcome = self .outcome (claim_draw = claim_draw )
2041
2062
return outcome .result () if outcome else "*"
2042
2063
0 commit comments