View source: R/can_knight_move.R
can_knight_move | R Documentation |
This function checks if a knight at a given position on a chess board has any legal moves.
can_knight_move(board, coordinates, color = board$to_move)
knight_can_move(board, coordinates, color = board$to_move)
board |
A list containing the current state of the chess board. |
coordinates |
A vector of length 2 representing the coordinates of the knight on the board. The first element is the row number and the second element is the column number. |
color |
An optional character vector giving the color of the knight. Defaults to the color of the player whose turn it is to move. |
See fen_to_board()
for details of the chess board format.
This function is used by other functions when testing for stalemate.
can_knight_move()
is an alias for knight_can_move()
.
A logical value indicating whether the knight has any legal moves (TRUE) or not (FALSE).
board <- fen_to_board() # Starting position
coordinates <- c(1, 2) # Coordinates of the white knight in the starting position
can_knight_move(board, coordinates)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.