is_check: Look for checks from enemy pieces

View source: R/is_check.R

is_checkR Documentation

Look for checks from enemy pieces

Description

This function returns TRUE if there are checks from enemy pieces, and FALSE otherwise.

Usage

is_check(board, color)

Arguments

board

An 8x8 matrix representing a chess position. See fen_to_board() for details of the board representation.

color

A string ("white" or "black"), indicating which king to examine.

Value

TRUE if the king is in check from an enemy piece, FALSE otherwise.

Examples

board <- fen_to_board('8/8/8/8/4k3/8/8/8 b - - 0 1')
print(board$board)
is_check(board$board, 'black')
board$board[3, 4] <- 'P'
print(board$board)
is_check(board$board, 'black')

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