Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Board ¶
Board represents a chess board and tracks pieces positions. It provides methods to move pieces and export board positions as FEN and GBR
func NewBoard ¶
func NewBoard() *Board
NewBoard returns a Board object initialized with the standard starting position
func NewBoardFromFen ¶
NewBoardFromFen returns a Board object initialized with the position of fen
func (*Board) Fen ¶
Fen returns the board position as a standard FEN string see http://en.wikipedia.org/wiki/Forsyth%E2%80%93Edwards_Notation
func (*Board) Gbr ¶
Gbr returns the GBR code for the position see http://en.wikipedia.org/wiki/GBR_code
func (*Board) LastMove ¶
LastMove returns the last move made on the board. In other words the position on the board resulted after this move
func (*Board) MakeMove ¶
MakeMove makes a move on the board If the move is illegal like a king move to a checked square or the move is ambiguous as if two pieces can move to the same square, then it returns an error and the board does not record the move. The board keeps track of which color moved previously and alternates
type Game ¶
type Game struct {
// Tags is a map with the PGN tags. The keys are the tag keys
Tags map[string]string
// Moves is initialized after calling ParseMovesText. It contains
// all the variations of the game as a tree of plies
Moves Variation
// PGNText is a verbatim copy of the game PGN
PGNText []byte
// MovesText contains just the game moves section from the PGN
MovesText []byte
}
Game represents a single parsed PGN game
func (*Game) ParseMovesText ¶
ParseMovesText parses the moves text of a game and converts it to a tree of plies. It must be called explicitly for each game
type Parser ¶
type Parser struct {
// contains filtered or unexported fields
}
Parser is a parser for the PGN chess games notation
type Ply ¶
type Ply struct {
// SAN is the text of the move like e4 or Nf3
SAN string
// Nags are pgn annotation for the move
Nags []uint8
// Comment is the comment for the move
Comment string
// Variations is a slice of alternative moves at this point.
// In PGN they are represented as RAVs parenthesized variations
Variations []Variation
}
Ply is a single move by white or black
type Variation ¶
type Variation struct {
// MoveNumber the move number at which the variation applies
MoveNumber uint8
// WhiteMove if true the variation starts with a ply by white, else by black
WhiteMove bool
// Plies is a slice with the plies of the variation
Plies []*Ply
// Result is the result of the variation. It is one of 1-0, 0-1, 1/2-1/2, *
Result string
// Comment has the comments from the PGN that apply to the variation as
// a whole and do not apply to specific plies
Comment string
}
Variation represents a singles variation i.e a move sequence in the game