move_exposes_king: Does the move expose the same-color king to check?

View source: R/move_exposes_king.R

move_exposes_kingR Documentation

Does the move expose the same-color king to check?

Description

This function creates a copy of the board and simulates a move. It then checks if the same-color king would be in check after the move.

Usage

move_exposes_king(board, coordinates, new_coordinates, color)

Arguments

board

A list containing the current state of the chess board.

coordinates

A vector of length 2 representing the coordinates of the piece on the board before the move. The first element is the row number and the second element is the column number.

new_coordinates

A vector of length 2 representing the coordinates of the piece on the board after the move. The first element is the row number and the second element is the column number.

color

A character vector giving the color of the piece.

Value

A Boolean indicating whether the move results in check.

Examples

board <- fen_to_board()
move_exposes_king(board, c(2, 1), c(3, 1), 'white')


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