king_can_move: Check if the king can move

View source: R/can_king_move.R

king_can_moveR Documentation

Check if the king can move

Description

This function checks if the king has any legal moves.

Usage

king_can_move(board, color = board$to_move)

can_king_move(board)

Arguments

board

A list containing the current state of the chess board.

color

An optional character vector giving the color of the king. Defaults to the color of the player whose turn it is to move.

Details

See fen_to_board() for details of the chess board format. This function is used by other functions when testing for checkmate or stalemate. can_king_move() is an alias for king_can_move().

Value

A logical value indicating whether the king can move. Returns TRUE if the king has at least one valid move, and FALSE otherwise.

Examples

board <- fen_to_board() # Starting position
king_can_move(board)


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