is_check_cpp: Test if a king is in check

View source: R/RcppExports.R

is_check_cppR Documentation

Test if a king is in check

Description

This function tests if a king is in check.

Usage

is_check_cpp(position, p)

Arguments

position

An 8 x 8 matrix representing the current position.

p

An integer indicating the color of the enemy pieces (1 for white, -1 for black).

Details

The function looks only at squares from which enemy pieces could attack the king based on the king's current position. If an attacking enemy piece is found in one of these squares, the function returns TRUE.

Value

A Boolean indicating if the king is in check.

Examples

# Initialize a chess board
position <- bigchess:::position.start()
# Is the white king in check?
is_check_cpp(position, -1)


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