Documentation ¶
Index ¶
Constants ¶
const ( WhitePawn = Piece(uint8(White)<<3 | uint8(Pawn)) WhiteKnight = Piece(uint8(White)<<3 | uint8(Knight)) WhiteBishop = Piece(uint8(White)<<3 | uint8(Bishop)) WhiteRook = Piece(uint8(White)<<3 | uint8(Rook)) WhiteQueen = Piece(uint8(White)<<3 | uint8(Queen)) WhiteKing = Piece(uint8(White)<<3 | uint8(King)) BlackPawn = Piece(uint8(Black)<<3 | uint8(Pawn)) BlackKnight = Piece(uint8(Black)<<3 | uint8(Knight)) BlackBishop = Piece(uint8(Black)<<3 | uint8(Bishop)) BlackRook = Piece(uint8(Black)<<3 | uint8(Rook)) BlackQueen = Piece(uint8(Black)<<3 | uint8(Queen)) BlackKing = Piece(uint8(Black)<<3 | uint8(King)) )
const NumSquares = 64
const StartingBoardFEN = "rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR"
const StartingPositionFEN = "rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR w KQkq - 0 1"
StartingPositionFEN is the FEN for the starting position.
Variables ¶
var ( PawnPushMasks [64]uint64 PawnAttackMasks [64]uint64 KnightAttackMasks [64]uint64 BishopAttackMasks [64]uint64 RookAttackMasks [64]uint64 QueenAttackMasks [64]uint64 KingAttackMasks [64]uint64 )
All masks are from White's viewpoint.
Functions ¶
This section is empty.
Types ¶
type Bitboard ¶
type Bitboard uint64
Bitboard is a 64-bit bitboard. From LSB to MSB, the bitboard goes A1, A2, ..., H8.
func (*Bitboard) Debug ¶
Debug returns a multi-line debug string representing the bitboard. True is "1", and false is ".".
type Board ¶
type Board struct {
// contains filtered or unexported fields
}
type CastlingFlag ¶
type CastlingFlag uint8
CastlingFlag represents a single castling right.
const ( // FriendOO represents the friendly king-side castling right. FriendOO CastlingFlag = 1 << iota // FriendOOO represents the friendly queen-side castling right. FriendOOO // EnemyOO represents the enemy king-side castling right. EnemyOO // EnemyOOO represents the enemy queen-side castling right. EnemyOOO )
type CastlingRights ¶
type CastlingRights uint8
CastlingRights represents all available castling rights.
func NewCastlingRights ¶
func NewCastlingRights(flags ...CastlingFlag) CastlingRights
NewCastlingRights returns a new CastlingRights with the provided rights set to true.
func ParseCastlingRightsFEN ¶
func ParseCastlingRightsFEN(s string) (CastlingRights, error)
func (*CastlingRights) Disable ¶
func (c *CastlingRights) Disable(f CastlingFlag)
Disable disables a castling right.
func (*CastlingRights) Enable ¶
func (c *CastlingRights) Enable(f CastlingFlag)
Enable enables a castling right.
func (*CastlingRights) FEN ¶
func (c *CastlingRights) FEN() string
FEN returns the FEN representation of the castling rights.
func (*CastlingRights) Get ¶
func (c *CastlingRights) Get(f CastlingFlag) bool
Get returns whether a castling right is available.
type Color ¶
type Color uint8
Color represents a color - either white or black.
func ParseColorFEN ¶
type EnPassantRight ¶
type EnPassantRight uint8
EnPassantRight represents the right to en passant.
func NewEnPassantRight ¶
func NewEnPassantRight() EnPassantRight
NewEnPassantRight returns a new EnPassantRight.
func ParseEnPassantRightFEN ¶
func ParseEnPassantRightFEN(s string) (EnPassantRight, error)
func (EnPassantRight) Allowed ¶
func (e EnPassantRight) Allowed() bool
Allowed returns whether en passant is allowed.
func (EnPassantRight) FEN ¶
func (e EnPassantRight) FEN() string
FEN returns the FEN representation of the EnPassantRight.
func (EnPassantRight) Flipped ¶
func (e EnPassantRight) Flipped() EnPassantRight
Flipped returns a new EnPassantRight with the target square vertically flipped (if any).
func (EnPassantRight) Get ¶
func (e EnPassantRight) Get() (Square, bool)
Get returns the target square (if any) and whether en passant is allowed.
type Position ¶
type Position struct { Board Board EnPassant EnPassantRight Castling CastlingRights SideToMove Color HalfMoveClock uint8 // Max half move clock is 75. FullMoveCount uint16 // Max full move count is ~4000 (?). }
Position represents a chess position.
func NewPosition ¶
NewPosition returns a new position set to the given FEN.
type Square ¶
type Square uint8
func ParseSquareFEN ¶
func (Square) EnPassantRight ¶
func (s Square) EnPassantRight() EnPassantRight
EnPassantRight returns an en passant right that targets the square.