fen

package
v0.10.1 Latest Latest
Warning

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

Go to latest
Published: Feb 14, 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.

Types

type FEN added in v0.5.0

type FEN struct {
	// contains filtered or unexported fields
}

func Encode

func Encode(board chess.Board) FEN

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 FromString added in v0.5.0

func FromString(str string) (FEN, error)

func (FEN) Castlings added in v0.5.0

func (f FEN) Castlings(side chess.Color) (short, long bool)

func (FEN) EnPassantSquare added in v0.5.0

func (f FEN) EnPassantSquare() chess.Position

func (FEN) HalfmoveClock added in v0.5.0

func (f FEN) HalfmoveClock() int

func (FEN) MoveNumber added in v0.5.0

func (f FEN) MoveNumber() int

func (FEN) Placement added in v0.5.0

func (f FEN) Placement() string

func (FEN) String added in v0.5.0

func (f FEN) String() string

func (FEN) Turn added in v0.5.0

func (f FEN) Turn() chess.Color

Jump to

Keyboard shortcuts

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