Documentation ¶
Overview ¶
Package hclibs ... Hastychess, Copyright (C) GPLv3, 2016, Kevin Colyer
Hastychess, Copyright (C) GPLv3, 2016, Kevin Colyer ¶
Hastychess, Copyright (C) GPLv3, 2016, Kevin Colyer ¶
Hastychess, Copyright (C) GPLv3, 2016, Kevin Colyer ¶
Hastychess, Copyright (C) GPLv3, 2016, Kevin Colyer ¶
Hastychess, Copyright (C) GPLv3, 2016, Kevin Colyer ¶
Hastychess, Copyright (C) GPLv3, 2016, Kevin Colyer ¶
Zorbist hashing functions (replaces a naive system of hashmaps and text string keys)
Hastychess, Copyright (C) GPLv3, 2016, Kevin Colyer
Index ¶
- Constants
- Variables
- func Abs(n int) int
- func AlgToDec(alg string) int
- func BLIND(m Move, p *Pos) bool
- func BoardToFEN(p *Pos) string
- func BoardToStr(p *Pos) string
- func BoardToStrColour(p *Pos) string
- func BoardToStrWide(p *Pos) string
- func Comma(i int) string
- func Commaf(i float64) string
- func DecToAlg(dec int) string
- func DeepPerftTest(t *testing.T)
- func Die(e string)
- func Divide(depth int, p *Pos) (nodesTotal int, s string)
- func DoesMoveCheckKing(m, Move, p *Pos) (b bool)
- func Eval(p *Pos, nummoves, gamestage int) int
- func EvalQ(p *Pos, nummoves, gamestage int) int
- func GameInit()
- func Gamestage(p *Pos) int
- func InCheck(king, side int, p *Pos) bool
- func InitBook()
- func InitHashSize(size int) (e error)
- func IsAttacked(square, side int, p *Pos) bool
- func IsLegalMove(m Move, p *Pos) (retval, check bool)
- func IsValidMove(m Move, p *Pos) bool
- func KingIsNear(look int, p *Pos) bool
- func MVVLVA(m Move, p *Pos) int
- func MakeMove(m Move, p *Pos)
- func MakeUserMove(m Move, p *Pos) (s string)
- func Max(a, b int) int
- func MhDistance(from, to int) int
- func Milliseconds(d time.Duration) int
- func Min(a, b int) int
- func MoveToAlg(m Move) (s string)
- func MoveToSAN(move Move) (san string)
- func NewRBCFEN(diff int) string
- func Offboard(i int) bool
- func Onboard(i int) bool
- func OrderMoves(moves *[]Move, p *Pos, pv *PV) bool
- func OtherSide(p Pos) int
- func Perft(depth int, p *Pos) (nodes int)
- func Pick(i int) int
- func PieceColour(piece int) int
- func PieceType(p int) int
- func PstScore(p *Pos, nummoves, gamestage int) (score int)
- func Rand64Reset()
- func SearchQuiesce(p *Pos, alpha, beta int, plys int, qdepth int, searchdepth int, srch *Search) int
- func Side(piece int) int
- func TTClear(hashtable int) bool
- func TTPerft(depth int, p *Pos) (nodes int)
- func TTPoke(key Hash, hashtable int, data TtData)
- func TtKey(p *Pos) string
- func UnMakeMove(m Move, p *Pos) bool
- func Xside(side int) int
- type EngineInfo
- type Fen
- type Hash
- type History
- type Move
- func AlgToMove(s string) (move Move)
- func ChooseBookMove(p *Pos) (move Move, success bool)
- func GenerateAllMoves(p *Pos) (moves []Move)
- func GenerateAllPseudoMoves(p *Pos) (moves []Move)
- func GenerateMoves(from int, p *Pos) (moves []Move)
- func GenerateMovesForQSearch(p *Pos) (moves []Move)
- func ParseUserMove(input string, p *Pos) (m Move, err string)
- func SearchRoot(p *Pos, srch *Search) (bestmove Move, bestscore int)
- type Movescore
- type PV
- type Pos
- type Proto
- type Search
- type Statistics
- type TtData
Constants ¶
const ( UNINITIALISED = 0 QUIET = 50 // sorted by history ENPASSANT = 51 KILLERS = 100 O_O_O = 200 O_O = 201 BADCAPTURE = 300 EPCAPTURE = 301 CAPTURE = 400 GOODCAPTURE = 500 PROMOTE = 600 PVBONUS = 700 INCHECK = 800 )
const (
A1, B1, C1, D1, E1, F1, G1, H1 = iota<<4 + 0, iota<<4 + 1, iota<<4 + 2, iota<<4 + 3, iota<<4 + 4, iota<<4 + 5, iota<<4 + 6, iota<<4 + 7
A2, B2, C2, D2, E2, F2, G2, H2 = iota<<4 + 0, iota<<4 + 1, iota<<4 + 2, iota<<4 + 3, iota<<4 + 4, iota<<4 + 5, iota<<4 + 6, iota<<4 + 7
A3, B3, C3, D3, E3, F3, G3, H3 = iota<<4 + 0, iota<<4 + 1, iota<<4 + 2, iota<<4 + 3, iota<<4 + 4, iota<<4 + 5, iota<<4 + 6, iota<<4 + 7
A4, B4, C4, D4, E4, F4, G4, H4 = iota<<4 + 0, iota<<4 + 1, iota<<4 + 2, iota<<4 + 3, iota<<4 + 4, iota<<4 + 5, iota<<4 + 6, iota<<4 + 7
A5, B5, C5, D5, E5, F5, G5, H5 = iota<<4 + 0, iota<<4 + 1, iota<<4 + 2, iota<<4 + 3, iota<<4 + 4, iota<<4 + 5, iota<<4 + 6, iota<<4 + 7
A6, B6, C6, D6, E6, F6, G6, H6 = iota<<4 + 0, iota<<4 + 1, iota<<4 + 2, iota<<4 + 3, iota<<4 + 4, iota<<4 + 5, iota<<4 + 6, iota<<4 + 7
A7, B7, C7, D7, E7, F7, G7, H7 = iota<<4 + 0, iota<<4 + 1, iota<<4 + 2, iota<<4 + 3, iota<<4 + 4, iota<<4 + 5, iota<<4 + 6, iota<<4 + 7
A8, B8, C8, D8, E8, F8, G8, H8 = iota<<4 + 0, iota<<4 + 1, iota<<4 + 2, iota<<4 + 3, iota<<4 + 4, iota<<4 + 5, iota<<4 + 6, iota<<4 + 7
)
const ( PROTOCONSOLE = iota + 1 PROTOXBOARD PROTOUCI )
const BISHOP = 5
const BLACK = 1
const CHECK = 20000 // sign dictates who we award it to
const CHECKMATE = 200000 // 200_000
const EAST = 1
const EMPTY = 0
WHITE
const ENDGAME = 2
const ETTHASH = 4
const INF = -NEGINF
const KING = 6
const KS = 1
const MAXSEARCHDEPTH = 10 // for manual play - easier to know what you have done wrong
const MAXSEARCHDEPTHX = 8 // for xboard
const MIDGAME = 1
const NE = NORTH + EAST
const NEGINF = -1000001 // -1_000_001
const NIGHT = 3
const NN = 32
const NORTH = 16
const NW = NORTH + WEST
const OPENING = 0
const PAWN = 1
const POSINF = INF
const PREVENTEXPLOSION = 2000000 // 2mil nodes to made debugging easier!!! TODO remove!
const PTTHASH = 3
const QS = 0
const QSTTHASH = 2
const QUEEN = 7
const QUIESCEDEPTH = 4
const ROOK = 4
const SE = SOUTH + EAST
const SOUTH = -16
const SS = -32
const STALEMATE = 0 // 50000
const STARTFEN = "rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR w KQkq - 0 1"
const SW = SOUTH + WEST
const TTEXACT = 1
const TTHASH = 1
const TTLOWER = 2
const TTMAXSIZE = 20 // (is 2^20=1048576 entries when over this oldest tt nodes are culled back so tt is this size
const TTUPPER = 3
const VERSION = "1.11 'Blockhead'"
const WEST = -1
const WHITE = 0
Variables ¶
var GRID = [64]int{ A1, B1, C1, D1, E1, F1, G1, H1, A2, B2, C2, D2, E2, F2, G2, H2, A3, B3, C3, D3, E3, F3, G3, H3, A4, B4, C4, D4, E4, F4, G4, H4, A5, B5, C5, D5, E5, F5, G5, H5, A6, B6, C6, D6, E6, F6, G6, H6, A7, B7, C7, D7, E7, F7, G7, H7, A8, B8, C8, D8, E8, F8, G8, H8, }
leapers
var NM = [8]int{31, 33, -31, -33, 14, 18, -14, -18}
pawn
var Pst [3][16][128]int
piece square table is for 3 phases of game, 12 different pieces and the game board squares for each
var REVGRID = [64]int{ A8, B8, C8, D8, E8, F8, G8, H8, A7, B7, C7, D7, E7, F7, G7, H7, A6, B6, C6, D6, E6, F6, G6, H6, A5, B5, C5, D5, E5, F5, G5, H5, A4, B4, C4, D4, E4, F4, G4, H4, A3, B3, C3, D3, E3, F3, G3, H3, A2, B2, C2, D2, E2, F2, G2, H2, A1, B1, C1, D1, E1, F1, G1, H1, }
REVGRID ... this is actually how we display the board on a screen or in FEN - top down !
var Zhash zhashstruct
Functions ¶
func BLIND ¶
Cargo culted from see.cpp of CPW engine ***************************************************************************** * This is not yet proper static exchange evaluation, but an approximation * * proposed by Harm Geert Mueller under the acronym BLIND (better, or lower * * if not defended. As the name indicates, it detects only obviously good * * captures, but it seems enough to improve move ordering. * *****************************************************************************
func BoardToFEN ¶
func BoardToStr ¶
func BoardToStrColour ¶
func BoardToStrWide ¶
func DeepPerftTest ¶
func DoesMoveCheckKing ¶
func InitHashSize ¶
initialises the hash to the size that the engine will set. size is given in human terms of number of entries e.g. 32M=32 million byte / 8 this needs to always be done only once. ics engine sends a command to do this. Xboard also. Conoles we keep it set at
func IsAttacked ¶
Is attacked - answers question is SQUARE attacked by SIDE
func IsLegalMove ¶
func IsValidMove ¶
func KingIsNear ¶
func MVVLVA ¶
Most Valuable Victim, Least Valuable Agressor best captures scored high, worst lowest (or negative)
func MakeUserMove ¶
func MhDistance ¶
func Milliseconds ¶
func PieceColour ¶
func Rand64Reset ¶
func Rand64Reset()
func SearchQuiesce ¶
func UnMakeMove ¶
Types ¶
type EngineInfo ¶
type EngineInfo struct { //Pv *PV //Stats *Statistics Pv PV Stats Statistics Info string }
func NewEngineInfo ¶
func NewEngineInfo(srch Search) EngineInfo
type Hash ¶
type Hash uint64
type History ¶
type History struct { TakenPieces [2]int JustTaken int Castled [4]bool King [2]int Side int InCheck int // -1 == no side in check either 1 or 0 EnPassant int // -1 == not in enpassant otherwise square to check Fifty int FullMoveClock int HalfMoveClock int Hash Hash // contains filtered or unexported fields }
type Move ¶
type Move struct {
// contains filtered or unexported fields
}
////////////////////////////////////////////////////////////////////////
func ChooseBookMove ¶
func GenerateAllMoves ¶
func GenerateAllPseudoMoves ¶
func GenerateMoves ¶
func GenerateMovesForQSearch ¶
func SearchRoot ¶
THIS SHOULD BE SEARCH ROOT OR A WAY TO ALLOW ME TO PLUG IN DIFFERENT SEARCHES
type Movescore ¶
type Movescore struct {
// contains filtered or unexported fields
}
/////////////////////////////////////////////////////////////////////
type PV ¶
type PV struct {
// contains filtered or unexported fields
}
//////////////////////////////////////////////////////////////////////// PV struct
type Pos ¶
type Pos struct { FEN string Board [128]int /* 0x88 board */ TakenPieces [2]int Castled [4]bool King [2]int Side int InCheck int // -1 == no side in check either 1 or 0 EnPassant int // -1 == not in enpassant otherwise square to check Fifty int FullMoveClock int HalfMoveClock int Ply int Hash Hash }
////////////////////////////////////////////////////////////////////////
func FENToBoard ¶
func FENToNewBoard ¶
type Search ¶
type Search struct { Stats *Statistics TimeStart time.Time MaxDurationOfSearch time.Duration FEN Fen P *Pos NewFEN Fen HistoryTable [128][128]int KillerTable [128][128]int Result string Info string PV *PV Score int BestMove Move Stop bool ExplosionLimit int MaxDepthToSearch int EngineInfoChan chan EngineInfo UseTT bool UseBook bool }
func (Search) StopSearch ¶
type Statistics ¶
type Statistics struct { Score int Nodes int QNodes int MaxDepthSearched int MaxQDepthSearched int TtHits int TtWrites int TtCulls int TtUpdates int UpperCuts int LowerCuts int AlphaRaised int BetaRaised int HtWrite int HtHit int KiWrite int KiHit int TimeElapsed time.Duration }
func (Statistics) String ¶
func (stat Statistics) String() string