board_to_fen | R Documentation |
The purpose of board_to_fen()
is simply to reverse the operation of
fen_to_board()
. As such, board_to_fen()
accepts as input a list
of game data (board
) in the format produced by fen_to_board()
.
board_to_fen(board)
board |
A list containing an 8x8 matrix of the board, whose trun it is, castling rights, en passant target square, halfmove clock, and fullmove number. |
Theboard
argument is a named list containing the same data as a FEN string,
but in a format that is more accessible in R:
$board
An 8x8 character matrix representing the chessboard, with lowercase
letters for the black pieces and uppercase for white.
$to_move
: Whose turn it is. Either 'w' or 'b'.
$castling_rights
: Which castling privileges remain. Can be any combination
of the characters 'K', 'Q', 'k', 'q', in order from uppercase to lowercase
and then king before queen to show queenside and kingside castling rights for
white or black, or '-' if no castling rights remain.
$ep_target
: If the previous move was a two-square pawn advance,
$ep_target
will give the name of the square where an enemy pawn capturing
en passant would land, even if no enemy pawn can currently capture
en passant. Otherwise, the value is '-'.
$halfmove_clock
: An integer for keeping track of the number of half moves
since the last pawn move or capture. Used to detect 50 move rule draws.
$fullmove_number
: An integer showing the current move number. Increases by
one after every black move.
See
section 16.1 of the PGN specification
for detailed information about the FEN format. Also see the documentation for
fen_to_board()
for more details about the board format.
A FEN string representing the board.
fen_to_board()
To convert a FEN string to a board matrix.
print_board()
Prints the board with rows in the correct order.
board <- fen_to_board()
board_to_fen(board)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.