Python-Chess board.is_checkmate, .is_stalemate, .is_en_passant, .is_check Always Returning True

984 Views Asked by At

Just downloaded the Python-Chess module and wanted to test it out; whenever I check the board state by using board.is_checkmate, board.is_stalemate, board.is_check, board.is_en_passant and a print statement, it always returns true. I'm using VSCode on macOS 11.3. Python version is 3.8.2.

import chess

board = chess.Board()

if board.is_checkmate:
    print("game over")
1

There are 1 best solutions below

0
On BEST ANSWER

You are checking if a method exists. You need to call the method and check what is returned. Adding brackets will complete this. This will call the method, which checks if the board is in this state.

import chess

board = chess.Board()

if board.is_checkmate():
    print("game over")

You can test this by printing "board.is_checkmate()" vs "board.is_checkmate" one will give true / false the other an address in memory that that method is stored.