common

package
v1.55.0 Latest Latest
Warning

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

Go to latest
Published: Jan 12, 2024 License: GPL-3.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const (
	FileAMask uint64 = 0x0101010101010101 << iota
	FileBMask
	FileCMask
	FileDMask
	FileEMask
	FileFMask
	FileGMask
	FileHMask
)
View Source
const (
	Rank1Mask uint64 = 0xFF << (8 * iota)
	Rank2Mask
	Rank3Mask
	Rank4Mask
	Rank5Mask
	Rank6Mask
	Rank7Mask
	Rank8Mask
)
View Source
const (
	FileA = iota
	FileB
	FileC
	FileD
	FileE
	FileF
	FileG
	FileH
)
View Source
const (
	Rank1 = iota
	Rank2
	Rank3
	Rank4
	Rank5
	Rank6
	Rank7
	Rank8
)
View Source
const (
	SquareA1 = iota
	SquareB1
	SquareC1
	SquareD1
	SquareE1
	SquareF1
	SquareG1
	SquareH1
	SquareA2
	SquareB2
	SquareC2
	SquareD2
	SquareE2
	SquareF2
	SquareG2
	SquareH2
	SquareA3
	SquareB3
	SquareC3
	SquareD3
	SquareE3
	SquareF3
	SquareG3
	SquareH3
	SquareA4
	SquareB4
	SquareC4
	SquareD4
	SquareE4
	SquareF4
	SquareG4
	SquareH4
	SquareA5
	SquareB5
	SquareC5
	SquareD5
	SquareE5
	SquareF5
	SquareG5
	SquareH5
	SquareA6
	SquareB6
	SquareC6
	SquareD6
	SquareE6
	SquareF6
	SquareG6
	SquareH6
	SquareA7
	SquareB7
	SquareC7
	SquareD7
	SquareE7
	SquareF7
	SquareG7
	SquareH7
	SquareA8
	SquareB8
	SquareC8
	SquareD8
	SquareE8
	SquareF8
	SquareG8
	SquareH8
)
View Source
const (
	SQUARE_NB = 64
	RANK_NB   = 8
	FILE_NB   = 8
	COLOUR_NB = 2
	PIECE_NB  = 8
)
View Source
const (
	SideWhite = 0
	SideBlack = 1
)
View Source
const (
	WhiteKingSide = 1 << iota
	WhiteQueenSide
	BlackKingSide
	BlackQueenSide
)
View Source
const (
	Empty int = iota
	Pawn
	Knight
	Bishop
	Rook
	Queen
	King
)
View Source
const InitialPositionFen = "rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR w KQkq - 0 1"
View Source
const (
	MaxMoves = 256
)
View Source
const MoveEmpty = Move(0)
View Source
const SquareNone = -1

Variables

View Source
var (
	SquareMask    [64]uint64
	KnightAttacks [64]uint64
	KingAttacks   [64]uint64
)

Functions

func AbsDelta

func AbsDelta(x, y int) int

func AllBlackPawnAttacks

func AllBlackPawnAttacks(b uint64) uint64

func AllWhitePawnAttacks

func AllWhitePawnAttacks(b uint64) uint64

func BitboardString

func BitboardString(b uint64) string

func Down

func Down(b uint64) uint64

func DownFill

func DownFill(gen uint64) uint64

func DownLeft

func DownLeft(b uint64) uint64

func DownRight

func DownRight(b uint64) uint64

func File

func File(sq int) int

func FileDistance

func FileDistance(sq1, sq2 int) int

func FileFill

func FileFill(gen uint64) uint64

func FirstOne

func FirstOne(b uint64) int

func FlipSquare

func FlipSquare(sq int) int

func IsDarkSquare

func IsDarkSquare(sq int) bool

func Left

func Left(b uint64) uint64

func MakeSquare

func MakeSquare(file, rank int) int

func Max

func Max(l, r int) int

func Min

func Min(l, r int) int

func MoreThanOne

func MoreThanOne(value uint64) bool

func ParseSquare

func ParseSquare(s string) int

func PawnAttacks

func PawnAttacks(from int, side bool) uint64

func PawnAttacksNew

func PawnAttacksNew(side, from int) uint64

func PopCount

func PopCount(b uint64) int

func QueenAttacks

func QueenAttacks(from int, occ uint64) uint64

func Rank

func Rank(sq int) int

func RankDistance

func RankDistance(sq1, sq2 int) int
func Right(b uint64) uint64

func RookAttacks

func RookAttacks(from int, occ uint64) uint64

func SquareDistance

func SquareDistance(sq1, sq2 int) int

func SquareName

func SquareName(sq int) string

func Up

func Up(b uint64) uint64

func UpFill

func UpFill(gen uint64) uint64

func UpLeft

func UpLeft(b uint64) uint64

func UpRight

func UpRight(b uint64) uint64

Types

type LimitsType

type LimitsType struct {
	Ponder         bool
	Infinite       bool
	WhiteTime      int
	BlackTime      int
	WhiteIncrement int
	BlackIncrement int
	MoveTime       int
	MovesToGo      int
	Depth          int
	Nodes          int
	Mate           int
}

type Move

type Move int32

func ParseMoveSAN

func ParseMoveSAN(pos *Position, san string) Move

func (Move) CapturedPiece

func (m Move) CapturedPiece() int

func (Move) From

func (m Move) From() int

func (Move) MovingPiece

func (m Move) MovingPiece() int

func (Move) Promotion

func (m Move) Promotion() int

func (Move) String

func (m Move) String() string

func (Move) To

func (m Move) To() int

type OrderedMove

type OrderedMove struct {
	Move Move
	Key  int32
}

type Position

type Position struct {
	Pawns, Knights, Bishops, Rooks, Queens, Kings, White, Black, Checkers uint64
	WhiteMove                                                             bool
	CastleRights, Rule50, EpSquare                                        int
	Key                                                                   uint64
	LastMove                                                              Move
}

func MirrorPosition

func MirrorPosition(p *Position) Position

func NewPositionFromFEN

func NewPositionFromFEN(fen string) (Position, error)

func (*Position) AllPieces

func (p *Position) AllPieces() uint64

func (*Position) Colours

func (p *Position) Colours(side int) uint64

func (*Position) GenerateCaptures

func (p *Position) GenerateCaptures(ml []OrderedMove) []OrderedMove

func (*Position) GenerateLegalMoves

func (p *Position) GenerateLegalMoves() []Move

func (*Position) GenerateMoves

func (p *Position) GenerateMoves(ml []OrderedMove) []OrderedMove

func (*Position) GetPieceTypeAndSide

func (p *Position) GetPieceTypeAndSide(sq int) (pieceType int, side bool)

func (*Position) IsCheck

func (p *Position) IsCheck() bool

func (*Position) IsRepetition

func (p *Position) IsRepetition(other *Position) bool

func (*Position) KingSq

func (p *Position) KingSq(side bool) int

func (*Position) MakeMove

func (src *Position) MakeMove(move Move, result *Position) bool

func (*Position) MakeMoveLAN

func (p *Position) MakeMoveLAN(lan string) (Position, bool)

func (*Position) MakeNullMove

func (src *Position) MakeNullMove(result *Position)

func (*Position) PiecesByColor

func (p *Position) PiecesByColor(side bool) uint64

func (*Position) String

func (p *Position) String() string

func (*Position) WhatPiece

func (p *Position) WhatPiece(sq int) int

type SearchInfo

type SearchInfo struct {
	Score    UciScore
	Depth    int
	Nodes    int64
	Time     time.Duration
	MainLine []Move
}

type SearchParams

type SearchParams struct {
	Positions []Position
	Limits    LimitsType
	Progress  func(si SearchInfo)
}

type UciScore

type UciScore struct {
	Centipawns int
	Mate       int
}

Jump to

Keyboard shortcuts

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