Documentation ¶
Overview ¶
Pieces movements in a chess board
Index ¶
- Constants
- func Bsf(bitboard Bitboard) int
- func Bsr(bitboard Bitboard) int
- type Bitboard
- type Color
- type Move
- type Piece
- type Position
- func (pos *Position) AddPiece(piece Piece, square string)
- func (pos *Position) AttackedSquares(side Color) (attackedSquares Bitboard)
- func (pos *Position) Check(side Color) (inCheck bool)
- func (pos *Position) CheckingPieces(side Color) (kingAttackers Bitboard)
- func (pos *Position) Checkmate(side Color) (checkmate bool)
- func (pos *Position) Divide(depth int) (divide string)
- func (pos *Position) EmptySquares() (emptySquares Bitboard)
- func (pos *Position) InsuficientMaterial() bool
- func (pos *Position) KingPosition(side Color) (king Bitboard)
- func (pos *Position) LegalMoves(side Color) (legalMoves []Move)
- func (pos *Position) MakeMove(move *Move)
- func (pos *Position) Perft(depth int) (nodes uint64)
- func (pos *Position) PieceAt(square string) (piece Piece, e error)
- func (pos *Position) Pieces(side Color) (pieces Bitboard)
- func (pos *Position) RemovePiece(piece Bitboard)
- func (pos *Position) Stealmate(side Color) (stealmate bool)
- func (pos *Position) String() string
- func (pos *Position) ToFen() (fen string)
- func (pos *Position) UnmakeMove(move Move)
Constants ¶
const ( Q = castling(0b0100) Qq = castling(0b0101) Qk = castling(0b0110) Qkq = castling(0b0111) K = castling(0b1000) Kq = castling(0b1001) Kk = castling(0b1010) Kkq = castling(0b1011) KQ = castling(0b1100) KQq = castling(0b1101) KQk = castling(0b1110) KQkq = castling(0b1111) )
const ( Normal = iota Castle PawnDoublePush EnPassant Promotion Capture )
Type of move
const ( NORTH uint64 = 0 NORTHEAST uint64 = 1 EAST uint64 = 2 SOUTHEAST uint64 = 3 SOUTH uint64 = 4 SOUTHWEST uint64 = 5 WEST uint64 = 6 NORTHWEST uint64 = 7 INVALID uint64 = 8 )
Constants for orthogonal directions in the board
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Bitboard ¶
type Bitboard uint64
Bitboard represents a bitboard as a 64bit integer
const AllSquares Bitboard = 0xFFFFFFFFFFFFFFFF
type Move ¶
type Move uint64
type Piece ¶
type Piece int
Piece is an int that references piece role/color for bitboards in position struct
type Position ¶
type Position struct { // Bitboards piece order -> King, Queen, Rook, Bishop, Knight, Pawn (first white, second black) Bitboards [12]Bitboard Turn Color Hash uint64 // contains filtered or unexported fields }
Position contains all information about a chess position
func EmptyPosition ¶
func EmptyPosition() (pos *Position)
EmptyPosition returns an empty Position struct
func InitialPosition ¶
func InitialPosition() (pos *Position)
InitialPosition is a factory that returns an initial postion board
func (*Position) AttackedSquares ¶
attackedSquares returns a bitboard with all squares attacked by the passed side
func (*Position) CheckingPieces ¶
checkingPieces returns an Bitboard of squares that contain pieces attacking the king of the side passed
func (*Position) Checkmate ¶
Checkmate returns if the passed side is in checkmate on the current position
func (*Position) Divide ¶
Divide, a variation of Perft, returns the perft of all moves in the current position
func (*Position) EmptySquares ¶
emptySquares returns a Bitboard with the empty sqaures of the position
func (*Position) InsuficientMaterial ¶
func (*Position) KingPosition ¶
KingPosition returns the bitboard of the passed side king
func (*Position) LegalMoves ¶
LegalMoves returns an slice of Move of all legal moves for the side passed
func (*Position) PieceAt ¶
pieceAt returns a Piece at the given square coordinate in the Position or error
func (*Position) RemovePiece ¶
Remove Piece returns a new position without the piece passed
func (*Position) Stealmate ¶
Stealmate returns if the passed side is in stealmate on the current position
func (*Position) UnmakeMove ¶
UnmakeMove undoes a the passed move in the postion