Documentation ¶
Index ¶
- Constants
- Variables
- func GetCapture(move int) int
- func GetFrom(move int) int
- func GetPieceValue(piece int) int
- func GetPromoted(move int) int
- func GetTo(move int) int
- func InitMvvLva()
- func Initialize()
- func MoveToString(move int) string
- func SquareToString(sq int) string
- func ToMove(from, to, capture, promotion, flag int) int
- type HashEnteryStruct
- type HashTableStruct
- type MoveListStruct
- type MoveStruct
- type PositionStruct
- func (pos *PositionStruct) CheckBoard() error
- func (pos *PositionStruct) ClearMoveFromHash() error
- func (pos *PositionStruct) Evaluate() int
- func (pos *PositionStruct) GenerateAllCaptureMoves(list *MoveListStruct) error
- func (pos *PositionStruct) GenerateAllMoves(list *MoveListStruct) error
- func (pos *PositionStruct) GetPvLine(depth int) (int, error)
- func (pos *PositionStruct) IsAttacked(sq, side int) (bool, error)
- func (pos *PositionStruct) IsRepition() bool
- func (pos *PositionStruct) LoadFEN(fen string) error
- func (pos *PositionStruct) MakeMove(move int) (bool, error)
- func (pos *PositionStruct) MakeNullMove() error
- func (pos *PositionStruct) MirrorBoard() error
- func (pos *PositionStruct) MoveExists(move int) (bool, error)
- func (pos *PositionStruct) ParseMove(move string) (int, error)
- func (pos *PositionStruct) Perft(depth int) (int, error)
- func (pos *PositionStruct) PerftDivide(depth int) error
- func (pos *PositionStruct) Print()
- func (pos *PositionStruct) ProbeHashEntry(move *int, score *int, alpha, beta, depth int) (bool, error)
- func (pos *PositionStruct) ProbePVMove() (int, error)
- func (pos *PositionStruct) StoreHashEntry(move, score, flags, depth int) error
- func (pos *PositionStruct) TakeMove() error
- func (pos *PositionStruct) TakeNullMove() error
- type UndoStruct
Constants ¶
const ( // HFNONE NONE flag for hash table HFNONE = iota // HFALPHA Alpha flag for hash table HFALPHA // HFBETA Beta flag for hash table HFBETA // HFEXACT Exact flag for hash table HFEXACT )
const Infinite = 30000
Infinite Largest score value
const IsMate = Infinite - MaxDepth
const MaxDepth = 64
MaxDepth The max depth the engine will try to search to
const NoMove = 0
NoMove constant for no move found
const SquareNumber = 120
SquareNumber Number of squares in the board representastion
const StartPosFEN = "rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR w KQkq - 0 0"
StartPosFEN The fen string for a starting position
Variables ¶
var DEBUG bool = false //Default set to true while debugging, should be false normally
DEBUG tells us if we should output debug messages
var MoveFlagCA = 0x1000000
MoveFlagCA Castel flag
var MoveFlagCAP = 0x7C000
MoveFlagCAP Capture flag
var MoveFlagEP = 0x40000
MoveFlagEP EnPas flag
var MoveFlagPROM = 0xF00000
MoveFlagPROM Promotion flag
var MoveFlagPS = 0x80000
MoveFlagPS Pawn Start flag
Functions ¶
func InitMvvLva ¶
func InitMvvLva()
InitMvvLva MvvLva (Most valuable victim least valuable attacker)
func SquareToString ¶
SquareToString square to algebraic notation
Types ¶
type HashEnteryStruct ¶
PVEnteryStruct The struct for each entry in the PV table
type HashTableStruct ¶
type HashTableStruct struct { Entries []HashEnteryStruct EntrieCount uint64 NewWrite int OverWrite int Hit int Cut int }
PVTableStruct Struct to hole the PVTable
func (*HashTableStruct) Init ¶
func (table *HashTableStruct) Init(hashSizeMB uint64)
initPVTables Initilize our PV Table slice with a exact amount of memory based on hashSizeMB
type MoveListStruct ¶
type MoveListStruct struct { Moves [maxPositionMoves]MoveStruct Count int }
MoveListStruct List of moves
func (*MoveListStruct) Print ¶
func (list *MoveListStruct) Print()
Print prints the move list struct to console
type PositionStruct ¶
type PositionStruct struct { Pieces [SquareNumber]int Pawns [3]uint64 KingSquare [2]int PieceNum [13]int BigPieces [2]int MajorPieces [2]int MinorPieces [2]int Material [2]int CastelPerm int Side int EnPassant int FiftyMove int Ply int HisPly int PosKey uint64 History [2048]UndoStruct PieceList [13][10]int HashTable HashTableStruct PvArray [MaxDepth]int SearchHistory [13][SquareNumber]int SearchKillers [2][MaxDepth]int }
PositionStruct the boards struct
func (*PositionStruct) CheckBoard ¶
func (pos *PositionStruct) CheckBoard() error
CheckBoard VERY expensive only use for debugging
func (*PositionStruct) ClearMoveFromHash ¶
func (pos *PositionStruct) ClearMoveFromHash() error
ClearMoveFromHash Clear the move made at the current position from the hash table
func (*PositionStruct) Evaluate ¶
func (pos *PositionStruct) Evaluate() int
Evaluate the currect position and return a score
func (*PositionStruct) GenerateAllCaptureMoves ¶
func (pos *PositionStruct) GenerateAllCaptureMoves(list *MoveListStruct) error
GenerateAllMoves Generate all moves
func (*PositionStruct) GenerateAllMoves ¶
func (pos *PositionStruct) GenerateAllMoves(list *MoveListStruct) error
GenerateAllMoves Generate all moves
func (*PositionStruct) GetPvLine ¶
func (pos *PositionStruct) GetPvLine(depth int) (int, error)
GetPvLine return the PVLine if found for the curren position
func (*PositionStruct) IsAttacked ¶
func (pos *PositionStruct) IsAttacked(sq, side int) (bool, error)
IsAttacked Returns if square is attacked
func (*PositionStruct) IsRepition ¶
func (pos *PositionStruct) IsRepition() bool
IsRepition tests for 3 fold repitition
func (*PositionStruct) LoadFEN ¶
func (pos *PositionStruct) LoadFEN(fen string) error
LoadFEN loads the engine with a new board position from a FEN string
func (*PositionStruct) MakeMove ¶
func (pos *PositionStruct) MakeMove(move int) (bool, error)
MakeMove Make a move if legal and return legality
func (*PositionStruct) MakeNullMove ¶
func (pos *PositionStruct) MakeNullMove() error
MakeNullMove Make a null move
For more info go to https://www.chessprogramming.org/Null_Move_Pruning
func (*PositionStruct) MirrorBoard ¶
func (pos *PositionStruct) MirrorBoard() error
mirrorBoard Mirror the position
func (*PositionStruct) MoveExists ¶
func (pos *PositionStruct) MoveExists(move int) (bool, error)
func (*PositionStruct) ParseMove ¶
func (pos *PositionStruct) ParseMove(move string) (int, error)
ParseMove algebraic notation to move int
func (*PositionStruct) Perft ¶
func (pos *PositionStruct) Perft(depth int) (int, error)
Perft is a performance test used to test move generation
returns leaf node count
For more information of Perft: https://www.chessprogramming.org/Perft
func (*PositionStruct) PerftDivide ¶
func (pos *PositionStruct) PerftDivide(depth int) error
PerftDivide divides the result of Perft() to each root node
returns leaf node count for a given root node
For more information of Perft: https://www.chessprogramming.org/Perft
func (*PositionStruct) Print ¶
func (pos *PositionStruct) Print()
Print a representation of the current board state to the console
func (*PositionStruct) ProbeHashEntry ¶
func (*PositionStruct) ProbePVMove ¶
func (pos *PositionStruct) ProbePVMove() (int, error)
ProbePVTable probe the table for a move on the current position
func (*PositionStruct) StoreHashEntry ¶
func (pos *PositionStruct) StoreHashEntry(move, score, flags, depth int) error
StorePVMove a move in the PV table
func (*PositionStruct) TakeMove ¶
func (pos *PositionStruct) TakeMove() error
TakeMove Take back the last move
func (*PositionStruct) TakeNullMove ¶
func (pos *PositionStruct) TakeNullMove() error
TakeNullMove Take back the last null move