is_checkmate: Check if the current board state is a checkmate

View source: R/is_checkmate.R

is_checkmateR Documentation

Check if the current board state is a checkmate

Description

Check if the current board state is a checkmate

Usage

is_checkmate(board, color = board$to_move)

Arguments

board

A list containing the 8x8 matrix board$board representing the game state and the color board$to_move of the player to move next.

color

The color of the player to check for checkmate. Default is board$to_move.

Value

TRUE if the player of the specified color is in checkmate, FALSE otherwise.

Examples

# Starting position
board <- fen_to_board()
is_checkmate(board)
# Fool's mate
board <- fen_to_board("rnbqkbnr/ppppp1pp/8/8/4pP1q/8/PPPPP1PP/RNBQKBNR w KQkq - 0 3")
is_checkmate(board)


dryguy/rbitr documentation built on Oct. 15, 2024, 6:18 a.m.