Documentation
¶
Overview ¶
Package fen contains functions for encoding the board into FEN encoding and vice versa.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ErrDecoding = errors.New("error decoding FEN string")
ErrDecoding is returned when there is an error decoding a FEN string.
Functions ¶
func Decode ¶
Decode decodes a FEN string into a chess board. The FEN string should match the regular expression defined in Regexp. It returns an error if the FEN string is invalid or if there is an error creating the board or pieces.
func Encode ¶
Encode encodes the given chess board into a FEN string. If the board is nil, it returns an empty string. If MetricFuncs are provided, it appends their results to the FEN string. The format of the FEN string is: <piece placement> <turn> [<metric1> <metric2> ...]. If no metrics are provided, it will only include the piece placement and turn. If metric functions return nil, it will append a dash ("-") for that metric.
func EncodeSquares ¶
EncodeSquares encodes the piece placement of the given squares into a FEN string. It iterates through the squares by rows and encodes each row. Each row is represented by a string of piece string representation, with empty squares represented by numbers.
Types ¶
This section is empty.