Documentation ¶
Index ¶
- func LmpMovesSearched(depth int) int
- func LmrReduction(depth int, movesSearched int) int
- type Limits
- type Result
- type Search
- func (s *Search) ClearHash()
- func (s *Search) GetUciHandlerPtr() uciInterface.UciDriver
- func (s *Search) IsReady()
- func (s *Search) IsSearching() bool
- func (s *Search) LastSearchResult() Result
- func (s *Search) NewGame()
- func (s *Search) NodesVisited() uint64
- func (s *Search) PonderHit()
- func (s *Search) ResizeCache()
- func (s *Search) SetUciHandler(uciHandler uciInterface.UciDriver)
- func (s *Search) StartSearch(p position.Position, sl Limits)
- func (s *Search) Statistics() *Statistics
- func (s *Search) StopSearch()
- func (s *Search) WaitWhileSearching()
- type Statistics
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func LmpMovesSearched ¶
LmpMovesSearched returns a depth dependent value for moves searched for late Move Prunings.
func LmrReduction ¶
LmrReduction returns the search depth reduction for LMR depended on depth and moves searched.
Types ¶
type Limits ¶
type Limits struct { // no time control Infinite bool Ponder bool Mate int // extra limits Depth int Nodes uint64 Moves moveslice.MoveSlice // time control TimeControl bool WhiteTime time.Duration BlackTime time.Duration WhiteInc time.Duration BlackInc time.Duration MoveTime time.Duration // parameter MovesToGo int }
Limits is data structure to hold all information about how a search of the chess games shall be controlled. Search needs to read these an determine the necessary limits. E.g. time controlled game or not
func NewSearchLimits ¶
func NewSearchLimits() *Limits
NewSearchLimits creates a new empty Limits instance and returns a pointer to it
type Result ¶
type Result struct { BestMove Move BestValue Value PonderMove Move SearchTime time.Duration SearchDepth int ExtraDepth int BookMove bool Pv moveslice.MoveSlice }
Result stores the result of a search. If BestMove is not MoveNone it can be assumed that all values are valid.
type Search ¶
type Search struct {
// contains filtered or unexported fields
}
Search represents the data structure for a chess engine search
Create new instance with NewSearch()
func NewSearch ¶
func NewSearch() *Search
NewSearch creates a new Search instance. If the given uci handler is nil all output will be sent to Stdout.
func (*Search) ClearHash ¶
func (s *Search) ClearHash()
ClearHash clears the transposition table. Is ignored with a warning while searching.
func (*Search) GetUciHandlerPtr ¶
func (s *Search) GetUciHandlerPtr() uciInterface.UciDriver
GetUciHandlerPtr returns the current UciHandler or nil if none is set.
func (*Search) IsReady ¶
func (s *Search) IsReady()
IsReady signals the uciHandler that the search is ready. This is part if the UCI protocol to make sure a chess engine is initialized and ready to receive commands. When called this will initialize the search which might take a while. When finished this will call the uciHandler set in SetUciHandler to send "readyok" to the UCI user interface.
func (*Search) IsSearching ¶
IsSearching checks if search is running.
func (*Search) LastSearchResult ¶
LastSearchResult returns a copy of the last search result.
func (*Search) NewGame ¶
func (s *Search) NewGame()
NewGame stops any running searches and resets the search state to be ready for a different game. Any caches or states will be reset.
func (*Search) NodesVisited ¶
NodesVisited returns the number of visited nodes in the last search.
func (*Search) PonderHit ¶
func (s *Search) PonderHit()
PonderHit is called by the UCI user interface when the engine has been instructed to ponder before. The engine usually is in search mode without time control when this is sent. This command will then activate time control without interrupting the running search. If no search is running this has no effect.
func (*Search) ResizeCache ¶
func (s *Search) ResizeCache()
ResizeCache resizes and clears the transposition table. Is ignored with a warning while searching.
func (*Search) SetUciHandler ¶
func (s *Search) SetUciHandler(uciHandler uciInterface.UciDriver)
SetUciHandler sets the UCI handler to communicate with the UCI user interface. If not set output will be sent to Stdout.
func (*Search) StartSearch ¶
StartSearch starts the search on the given position with the given search limits. Search can be stopped with StopSearch(). Search status can be checked with IsSearching() This takes a copy of the position and the search limits.
func (*Search) Statistics ¶
func (s *Search) Statistics() *Statistics
Statistics returns a pointer to the search statistics of the last search.
func (*Search) StopSearch ¶
func (s *Search) StopSearch()
StopSearch stops a running search as quickly as possible. The search stops gracefully and a result will be sent to UCI. This will wait for the search to be stopped before returning.
func (*Search) WaitWhileSearching ¶
func (s *Search) WaitWhileSearching()
WaitWhileSearching checks if search is running and blocks until search has stopped.
type Statistics ¶
type Statistics struct { QFpPrunings uint64 BestMoveChange uint64 AspirationResearches uint64 BetaCuts uint64 BetaCuts1st uint64 RfpPrunings uint64 FpPrunings uint64 ThreatExtension uint64 NMPMateAlpha uint64 NMPMateBeta uint64 CheckExtension uint64 CheckInQS uint64 LmpCuts uint64 LmrResearches uint64 LmrReductions uint64 Evaluations uint64 EvaluationsFromTT uint64 TTHit uint64 TTMiss uint64 TTMoveUsed uint64 NoTTMove uint64 TTCuts uint64 TTNoCuts uint64 IIDmoves uint64 IIDsearches uint64 LeafPositionsEvaluated uint64 Checkmates uint64 Stalemates uint64 RootPvsResearches uint64 PvsResearches uint64 NullMoveCuts uint64 StandpatCuts uint64 Mdp uint64 CurrentIterationDepth int CurrentSearchDepth int CurrentExtraSearchDepth int CurrentVariation moveslice.MoveSlice CurrentRootMoveIndex int CurrentRootMove Move CurrentBestRootMove Move CurrentBestRootMoveValue Value }
Statistics are extra data and stats not essential for a functioning search
func (*Statistics) String ¶
func (s *Statistics) String() string