searchctl

package
v0.91.1 Latest Latest
Warning

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

Go to latest
Published: Dec 18, 2023 License: MIT Imports: 12 Imported by: 0

Documentation

Overview

Package searchctl contains search functionality and utilities.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func EnforceTimeControl

func EnforceTimeControl(ctx context.Context, h Handle, tc lang.Optional[TimeControl], turn board.Color) (time.Duration, bool)

EnforceTimeControl enforces the time control limits, if any. Returns soft limit.

Types

type Handle

type Handle interface {
	// Halt halts the search, if running. Idempotent.
	Halt() search.PV
}

Handle is an interface for the engine to manage searches. The engine is expected to spin off searches with forked boards and close/abandon them when no longer needed. This design keeps stopping conditions and re-synchronization trivial.

type Iterative

type Iterative struct {
	Root search.Search
}

Iterative is a search harness for iterative deepening search.

func (*Iterative) Launch

func (i *Iterative) Launch(ctx context.Context, b *board.Board, tt search.TranspositionTable, noise eval.Random, opt Options) (Handle, <-chan search.PV)

type Launcher

type Launcher interface {
	// Launch a new search from the given position. It expects an exclusive (forked) board and
	// returns a PV channel for iteratively deeper searches. If the search is exhausted, the
	// channel is closed. The search can be stopped at any time.
	Launch(ctx context.Context, b *board.Board, tt search.TranspositionTable, noise eval.Random, opt Options) (Handle, <-chan search.PV)
}

Launcher is an interface for managing searches.

type Options

type Options struct {
	// DepthLimit, if set, limits the search to the given ply depth. Zero means no limit.
	DepthLimit lang.Optional[uint]
	// TimeControl, if set, limits the search to the given time parameters.
	TimeControl lang.Optional[TimeControl]
}

Options hold dynamic search options. The user may change these on a particular search.

func (Options) String

func (o Options) String() string

type TimeControl

type TimeControl struct {
	White, Black time.Duration
	Moves        int // 0 == rest of game
}

TimeControl represents time control information.

func (TimeControl) Limits

func (t TimeControl) Limits(c board.Color) (time.Duration, time.Duration)

Limits returns a soft and hard limit for making move with the given color. The interpretation is that after the soft limit, no new search should be conducted.

func (TimeControl) String

func (t TimeControl) String() string

Jump to

Keyboard shortcuts

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