core

package
v0.0.0-...-a709619 Latest Latest
Warning

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

Go to latest
Published: Mar 4, 2025 License: MIT Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func MoveNumber

func MoveNumber(fen []string) (n uint8, err error)

func PlayingTurn

func PlayingTurn(fen []string) (c chess.Color, err error)

func RemoveDiacritics

func RemoveDiacritics(s string) string

Types

type Game

type Game []Move

func ParseGame

func ParseGame(moves string) (g Game, err error)

func (Game) ContainsMoves

func (g Game) ContainsMoves(moves []*chess.Move) bool

func (Game) ContainsPosition

func (g Game) ContainsPosition(pos *chess.Position) bool

func (Game) Empty

func (g Game) Empty() bool

type GameID

type GameID [8]uint8

func ParseGameID

func ParseGameID(str string) (id GameID)

func ParseGameIDFromURL

func ParseGameIDFromURL(url string) (id GameID)

func (GameID) String

func (id GameID) String() string

type GamesIndex

type GamesIndex map[GameID]Game

func (GamesIndex) Insert

func (i GamesIndex) Insert(id, moves string) error

func (GamesIndex) InsertFromChess

func (i GamesIndex) InsertFromChess(id GameID, chessGame *chess.Game)

type Index

type Index struct {
	Openings OpeningsIndex
	Games    GamesIndex
	Puzzles  PuzzlesIndex
}

func LoadIndex

func LoadIndex() (*Index, error)

func (*Index) SearchOpening

func (s *Index) SearchOpening(game *chess.Game) (found OpeningName, leftover []*chess.Move)

func (*Index) SearchPuzzles

func (s *Index) SearchPuzzles(
	chessGame *chess.Game,
	strategy SearchType,
	turn chess.Color,
	maxMoves uint8,
) []PuzzleData

type Move

type Move struct {
	From  chess.Square
	To    chess.Square
	Promo chess.PieceType
	Tags  chess.MoveTag
}

func GameFromChess

func GameFromChess(move *chess.Move) Move

func (Move) String

func (m Move) String() string

type OpeningName

type OpeningName [2]string

func ParseOpeningName

func ParseOpeningName(s string) (n OpeningName)

func (OpeningName) Empty

func (n OpeningName) Empty() bool

func (OpeningName) Family

func (n OpeningName) Family() string

func (OpeningName) FamilyTag

func (n OpeningName) FamilyTag() string

func (OpeningName) String

func (n OpeningName) String() string

func (OpeningName) Tag

func (n OpeningName) Tag() string

func (OpeningName) Variation

func (n OpeningName) Variation() string

func (OpeningName) VariationTag

func (n OpeningName) VariationTag() string

type OpeningsIndex

type OpeningsIndex map[[16]byte]OpeningName

func (OpeningsIndex) Insert

func (i OpeningsIndex) Insert(name, moves string) error

type Position

type Position struct{ chess.Position }

func PositionFromChess

func PositionFromChess(p *chess.Position) Position

func (*Position) GobDecode

func (p *Position) GobDecode(data []byte) (err error)

func (Position) GobEncode

func (p Position) GobEncode() (out []byte, err error)

func (Position) Hash

func (p Position) Hash() [16]byte

type PuzzleData

type PuzzleData struct {
	Move   uint8
	Turn   chess.Color
	ID     PuzzleID
	GameID GameID
}

func NewPuzzleData

func NewPuzzleData(id, gameURL, fen string) (d PuzzleData, err error)

func (*PuzzleData) GobDecode

func (d *PuzzleData) GobDecode(data []byte) (err error)

func (PuzzleData) GobEncode

func (d PuzzleData) GobEncode() (out []byte, err error)

func (PuzzleData) URL

func (d PuzzleData) URL() (url string)

type PuzzleID

type PuzzleID [5]uint8

func ParsePuzzleID

func ParsePuzzleID(s string) (id PuzzleID)

func (PuzzleID) String

func (id PuzzleID) String() string

type PuzzlesIndex

type PuzzlesIndex map[string][]PuzzleData

func (PuzzlesIndex) Filter

func (i PuzzlesIndex) Filter(openingTag string, side chess.Color, maxMoves uint8) iter.Seq[PuzzleData]

func (PuzzlesIndex) Insert

func (i PuzzlesIndex) Insert(puzzleID, fen, gameURL, openingTags string) error

type SearchType

type SearchType int8
const (
	MoveSequenceSearch SearchType = iota
	PositionSearch
)

func (SearchType) String

func (t SearchType) String() string

type Turn

type Turn int8
const (
	EitherTurn Turn = iota
	WhiteTurn
	BlackTurn
)

func (Turn) String

func (t Turn) String() string

func (Turn) ToChess

func (t Turn) ToChess() chess.Color

Jump to

Keyboard shortcuts

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