View source: R/can_pawn_move.R
can_pawn_move | R Documentation |
This function checks if a pawn at a given position on a chess board can move forward one square, capture an enemy piece diagonally, or perform an en passant capture.
can_pawn_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 pawn 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 pawn. Defaults to the color of the player whose turn it is to move. |
A logical value indicating whether the pawn can move forward one square, capture an enemy piece diagonally, or perform an en passant capture (TRUE) or not (FALSE).
board <- fen_to_board() # Starting position
coordinates <- c(2, 1) # Coordinates of the white pawn in the starting position
can_pawn_move(board, coordinates)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.