board

package
v0.0.0-...-1a8bede Latest Latest
Warning

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

Go to latest
Published: Apr 19, 2024 License: GPL-3.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var EgTables = [6][64]int{pawnEG, knightEG, bishopEG, rookEG, queenEG, kingEG}
View Source
var MgTables = [6][64]int{pawnMG, knightMG, bishopMG, rookMG, queenMG, kingMG}

Functions

func ContainsN

func ContainsN[T IntArray](n int8, nums T) bool

Linear search for small arrays

func GetFiles

func GetFiles() [4][8]int8

func RestorePosition

func RestorePosition(pos *Position, cb *Board)

Types

type Board

type Board struct {
	// TODO: move occupancies into one array? Possible memory speed boost
	// White to move. 1=true, 0=false. Use uint because bools cannot be xor'd
	WToMove uint
	Zobrist uint64

	Pieces  [2]uint64
	Pawns   [2]uint64
	Knights [2]uint64
	Bishops [2]uint64
	Rooks   [2]uint64
	Queens  [2]uint64
	Kings   [2]uint64

	KingSqs      [2]int8
	CastleRights [2][2]bool // [b, w][queenside, kingside]

	EpSquare  int8
	PrevMove  Move
	HalfMoves uint8

	EvalMaterial   int
	PiecePhaseSum  int
	EvalMidGamePST int // piece-square tables (PST)
	EvalEndGamePST int
}

func FromFen

func FromFen(fen string) (*Board, error)

Build a Board object from a Forsyth-Edwards notation (FEN) string example: "rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR w KQkq - 0 1"

func New

func New() *Board

func (*Board) Print

func (cb *Board) Print()

type IntArray

type IntArray interface {
	[8]int8 | [4]int8 | [3]int8
}

type Move

type Move struct {
	From, To         int8
	Piece, PromoteTo uint8
}

type Position

type Position struct {
	WToMove uint
	Zobrist uint64

	Pieces  [2]uint64
	Pawns   [2]uint64
	Knights [2]uint64
	Bishops [2]uint64
	Rooks   [2]uint64
	Queens  [2]uint64
	Kings   [2]uint64

	KingSqs      [2]int8
	CastleRights [2][2]bool

	EpSquare  int8
	PrevMove  Move
	HalfMoves uint8

	EvalMaterial   int
	PiecePhaseSum  int
	EvalMidGamePST int
	EvalEndGamePST int
}

func StorePosition

func StorePosition(cb *Board) *Position

type Zobrist

type Zobrist struct {
	ColorPieceSq [2][6][64]uint64
	BToMove      uint64
	Castle       [2][2]uint64
	EpFile       [8]uint64
}
var ZobristKeys Zobrist = buildZobristKeys()

Jump to

Keyboard shortcuts

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