chess

package module
v0.0.0-...-a8fddb1 Latest Latest
Warning

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

Go to latest
Published: Mar 16, 2021 License: MIT Imports: 6 Imported by: 0

Documentation

Index

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

func (chess *Chess) GameOver() bool

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

func (chess *Chess) GenerateFen() string

GenerateFen builds and returns the FEN encoding of the current board

func (*Chess) Get

func (chess *Chess) Get(squareID string) Piece

Get returns the Piece at the given square or an unspecified Piece if the square is unoccupied

func (*Chess) InCheck

func (chess *Chess) InCheck() bool

InCheck returns true if the side to move is in check

func (*Chess) InCheckmate

func (chess *Chess) InCheckmate() bool

InCheckmate returns true if the side to move is in checkmate

func (*Chess) InDraw

func (chess *Chess) InDraw() bool

InDraw returns true if we've made more than 100 half moves, in stalemate, insufficient material or in threefold repetition

func (*Chess) InStalemate

func (chess *Chess) InStalemate() bool

InStalemate returns true if the side to move is in stalemate

func (*Chess) InThreefoldRepition

func (chess *Chess) InThreefoldRepition() bool

InThreefoldRepition returns true or false if the current board position has occurred three or more times.

func (*Chess) InsufficientMaterial

func (chess *Chess) InsufficientMaterial() bool

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

func (chess *Chess) Load(fenToLoad string) error

Load clears the board and sets up the board according to the FEN encoded string if it is legal FEN

func (*Chess) Move

func (chess *Chess) Move(san string) error

Move parses the given san and makes that move. Returns an error if the SAN was not le

func (*Chess) Moves

func (chess *Chess) Moves(legalMoves bool, singleSquareName string) []Move

Moves returns all the moves available for the board, the specified single square or the legal moves for either of those

func (*Chess) Put

func (chess *Chess) Put(piece Piece, squareName string) error

Put puts the given piece on the specified square

func (*Chess) Remove

func (chess *Chess) Remove(squareID string) Piece

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

func (chess *Chess) SANToMove(san string) (Move, error)

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

func (*Chess) Undo

func (chess *Chess) Undo() (Move, bool)

Undo takes the most recently pushed history item and undoes it's effects

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

func (p *Piece) IsUnspecified() bool

IsUnspecified returns true if this the piece given is doesn't have a type or a color

type PieceColor

type PieceColor int

PieceColor is either black or white

type PieceType

type PieceType int

PieceType identifies the type of a piece.

type Stack

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

Stack is a simple stack for stuff

func (*Stack) Len

func (stack *Stack) Len() int

Len returns how many items are in the stack

func (*Stack) Pop

func (stack *Stack) Pop() interface{}

Pop removes the top most item from the stack

func (*Stack) Push

func (stack *Stack) Push(value interface{})

Push adds a value onto the stack

Jump to

Keyboard shortcuts

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