fen

package
v0.4.3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 11, 2026 License: GPL-3.0 Imports: 15 Imported by: 0

Documentation

Overview

Package fen contains functions for encoding the board into FEN encoding and vice versa.

Index

Constants

This section is empty.

Variables

View Source
var ErrDecoding = errors.New("error decoding FEN string")

ErrDecoding is returned when there is an error decoding a FEN string.

Functions

func Decode

func Decode(fen string) (chess.Board, error)

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

func Encode(board chess.Board) string

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

func EncodeSquares(squares *chess.Squares) string

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.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL