Documentation
¶
Index ¶
- type Chess
- func (chess *Chess) Clear()
- func (chess *Chess) GameOver() bool
- func (chess *Chess) GenerateFen() string
- func (chess *Chess) Get(squareID string) Piece
- func (chess *Chess) InCheck() bool
- func (chess *Chess) InCheckmate() bool
- func (chess *Chess) InDraw() bool
- func (chess *Chess) InStalemate() bool
- func (chess *Chess) InThreefoldRepition() bool
- func (chess *Chess) InsufficientMaterial() bool
- func (chess *Chess) Load(fenToLoad string) error
- func (chess *Chess) Move(san string) error
- func (chess *Chess) Moves(legalMoves bool, singleSquareName string) []Move
- func (chess *Chess) Put(piece Piece, squareName string) error
- func (chess *Chess) Remove(squareID string) Piece
- func (chess *Chess) Reset()
- func (chess *Chess) SANToMove(san string) (Move, error)
- func (chess *Chess) Turn() PieceColor
- func (chess *Chess) Undo() (Move, bool)
- type Fen
- type Move
- type Piece
- type PieceColor
- type PieceType
- type Stack
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Chess ¶
type Chess struct {
// contains filtered or unexported fields
}
Chess defines the current structure of a chess game
func New ¶
func New() *Chess
New creates a new Chess instance initialized to the starting/default chess position
func (*Chess) Clear ¶
func (chess *Chess) Clear()
Clear sets the Chess instance to the starting position
func (*Chess) GameOver ¶
GameOver returns true if we've made more than 100 half moves, in checkmate, in stalemate, insufficient material or in threefold repetition//
func (*Chess) GenerateFen ¶
GenerateFen builds and returns the FEN encoding of the current board
func (*Chess) Get ¶
Get returns the Piece at the given square or an unspecified Piece if the square is unoccupied
func (*Chess) InCheckmate ¶
InCheckmate returns true if the side to move is in checkmate
func (*Chess) InDraw ¶
InDraw returns true if we've made more than 100 half moves, in stalemate, insufficient material or in threefold repetition
func (*Chess) InStalemate ¶
InStalemate returns true if the side to move is in stalemate
func (*Chess) InThreefoldRepition ¶
InThreefoldRepition returns true or false if the current board position has occurred three or more times.
func (*Chess) InsufficientMaterial ¶
InsufficientMaterial returnsif the game is drawn due to insufficient material (K vs. K, K vs. KB, or K vs. KN); otherwise false.
func (*Chess) Load ¶
Load clears the board and sets up the board according to the FEN encoded string if it is legal FEN
func (*Chess) Move ¶
Move parses the given san and makes that move. Returns an error if the SAN was not le
func (*Chess) Moves ¶
Moves returns all the moves available for the board, the specified single square or the legal moves for either of those
func (*Chess) Remove ¶
Remove removes the piece from the given square and returns it. An empty square will return an unspecified Piece (Piece.IsUnspecified() == true)
func (*Chess) Reset ¶
func (chess *Chess) Reset()
Reset sets the board to the default/starting position
func (*Chess) SANToMove ¶
SANToMove converts a SAN encoded string into a Move, if it's a legal move, or returns an error
func (*Chess) Turn ¶
func (chess *Chess) Turn() PieceColor
Turn returns the color of the side to move
type Fen ¶
type Fen struct {
// contains filtered or unexported fields
}
Fen deals with FEN encoded strings. See https://en.wikipedia.org/wiki/Forsyth%E2%80%93Edwards_Notation
type Move ¶
type Move struct {
// contains filtered or unexported fields
}
Move describes a move on the board
type Piece ¶
type Piece struct {
// contains filtered or unexported fields
}
Piece represents a piece on the board, having a type such as pawn or bishop and a color, white or black
func (*Piece) IsUnspecified ¶
IsUnspecified returns true if this the piece given is doesn't have a type or a color