Skip to content

Commit 0e900e2

Browse files
authored
Merge pull request #1168 from hyprchs/master
Add `Board.gives_checkmate()`
2 parents 4d9b3bf + f8575f9 commit 0e900e2

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

chess/__init__.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1980,6 +1980,17 @@ def gives_check(self, move: Move) -> bool:
19801980
finally:
19811981
self.pop()
19821982

1983+
def gives_checkmate(self, move: Move) -> bool:
1984+
"""
1985+
Probes if the given move would put the opponent in checkmate. The move
1986+
must be at least pseudo-legal.
1987+
"""
1988+
self.push(move)
1989+
try:
1990+
return self.is_checkmate()
1991+
finally:
1992+
self.pop()
1993+
19831994
def is_into_check(self, move: Move) -> bool:
19841995
king = self.king(self.turn)
19851996
if king is None:

0 commit comments

Comments
 (0)