pgn

package
v0.0.0-...-b4b1fef Latest Latest
Warning

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

Go to latest
Published: Feb 28, 2024 License: GPL-3.0 Imports: 17 Imported by: 0

Documentation

Index

Constants

View Source
const (
	TERM_NORMAL = "Normal"
	TERM_TIME   = "Time forfeit"
)
View Source
const (
	TC_BULLET    = 0
	TC_BLITZ     = 3 * 60
	TC_RAPID     = 10 * 60
	TC_CLASSICAL = 60 * 60
)

Upper bounds for adjusted time per game (seconds), bullet assumes 40move game, blitz, rapid 60 move game.

Variables

This section is empty.

Functions

func PreFilter

func PreFilter(tag Tag, value string) bool

Filter conditions that can be determined on individual Tags.

func SANToMove

func SANToMove(b *board.Board, san string) (board.Move, error)

Types

type ByteCountingReader

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

Reader that keeps track on the bytes read. Useful for reading compressed files and estimateing their compression by wrapping input and output readers (i.e. input: file, output: decompressed data read).

func (*ByteCountingReader) Read

func (bcr *ByteCountingReader) Read(p []byte) (n int, err error)

type Bzip2PGN

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

func NewBzip2PGN

func NewBzip2PGN(path string) *Bzip2PGN

func (*Bzip2PGN) BytesRead

func (s *Bzip2PGN) BytesRead() bytesize.ByteSize

func (*Bzip2PGN) Close

func (s *Bzip2PGN) Close() error

func (*Bzip2PGN) Open

func (s *Bzip2PGN) Open() error

func (*Bzip2PGN) Scan

func (s *Bzip2PGN) Scan() bool

func (*Bzip2PGN) Size

func (s *Bzip2PGN) Size() bytesize.ByteSize

func (*Bzip2PGN) Text

func (s *Bzip2PGN) Text() string

type PGN

type PGN struct {
	Event string
	// White       string
	// Black       string
	Result string
	// WhiteElo    string
	// BlackElo    string
	// ECO         string
	Moves string
}

func (*PGN) AddTag

func (pgn *PGN) AddTag(tag Tag, value string) *PGN

func (*PGN) GetAnnotations

func (pgn *PGN) GetAnnotations() []string

func (*PGN) GetFENs

func (pgn *PGN) GetFENs() []string

func (*PGN) PostFilter

func (pgn *PGN) PostFilter() bool

Filter conditions that dependant on a combination of tags. ie Elo difference TODO: function stub.

func (*PGN) RemoveAnnotations

func (pgn *PGN) RemoveAnnotations() string

type PGNs

type PGNs []PGN

type Parser

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

func NewPGNParser

func NewPGNParser(source Source, filtered bool) (*Parser, error)

func (*Parser) Close

func (pp *Parser) Close() error

func (*Parser) PGN

func (pp *Parser) PGN() *PGN

func (*Parser) Progress

func (pp *Parser) Progress(_ bool)

func (*Parser) Scan

func (pp *Parser) Scan(ctx context.Context) bool

Scan the PGN file for the next game meeting the criteria defined by filters. The game can be accessed by calling the PGN method.

type PlainPGN

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

func NewPlainPGN

func NewPlainPGN(path string) *PlainPGN

func (*PlainPGN) BytesRead

func (s *PlainPGN) BytesRead() bytesize.ByteSize

func (*PlainPGN) Close

func (s *PlainPGN) Close() error

func (*PlainPGN) Open

func (s *PlainPGN) Open() error

func (*PlainPGN) Scan

func (s *PlainPGN) Scan() bool

func (*PlainPGN) Size

func (s *PlainPGN) Size() bytesize.ByteSize

func (*PlainPGN) Text

func (s *PlainPGN) Text() string

type Source

type Source interface {
	Open() error
	Close() error
	Scan() bool
	Text() string
	// The size (or estimated size in case of archives) of the data
	Size() bytesize.ByteSize
	// Fraction of data that has been read. Bounded by 1 in case of bad estimates
	BytesRead() bytesize.ByteSize
}

func ParsePath

func ParsePath(pgnPath string) ([]Source, error)

type Tag

type Tag string
const (
	TAG_EVENT       Tag = "Event"
	TAG_SITE        Tag = "Site"
	TAG_DATE        Tag = "Date"
	TAG_ROUND       Tag = "Round"
	TAG_WHITE       Tag = "White"
	TAG_BLACK       Tag = "Black"
	TAG_RESULT      Tag = "Result"
	TAG_TERMINATION Tag = "Termination"
	TAG_TIMECONTROL Tag = "TimeControl"
	TAG_ECO         Tag = "ECO"
	TAG_WHITE_ELO   Tag = "WhiteElo"
	TAG_BLACK_ELO   Tag = "BlackElo"
)

type ZstPGN

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

func NewZstPGN

func NewZstPGN(path string) *ZstPGN

func (*ZstPGN) BytesRead

func (s *ZstPGN) BytesRead() bytesize.ByteSize

func (*ZstPGN) Close

func (s *ZstPGN) Close() error

func (*ZstPGN) Open

func (s *ZstPGN) Open() error

func (*ZstPGN) Scan

func (s *ZstPGN) Scan() bool

func (*ZstPGN) Size

func (s *ZstPGN) Size() bytesize.ByteSize

func (*ZstPGN) Text

func (s *ZstPGN) Text() string

Jump to

Keyboard shortcuts

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