Skip to content

Instantly share code, notes, and snippets.

@NicolaM94
Last active February 7, 2023 00:40
Check mate or not
otherPiecesMoves = Pawn(7,2).possibleMoves() + Tower(5,3).possibleMoves() + Bishop(2,7).possibleMoves() + Queen(3,2).possibleMoves()+ Knight(6,6).possibleMoves()
king = King(5,8)
print("King's moves: ",king.possibleMoves())
stillAliveMoves = []
for m in king.possibleMoves():
if m not in otherPiecesMoves:
stillAliveMoves.append(m)
if len(stillAliveMoves) == 0:
print("Check mate!")
else:
print("Possible moves: ",stillAliveMoves)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment