Trait alcibiades::SearchExecutor [] [src]

pub trait SearchExecutor: SetOption {
    type HashTable: HashTable;
    type SearchNode: SearchNode;
    type ReportData;
    fn new(tt: Arc<Self::HashTable>) -> Self;
    fn start_search(&mut self,
                    params: SearchParams<Self::SearchNode>,
                    time: Option<&RemainingTime>); fn try_recv_report(&mut self)
                       -> Result<SearchReport<Self::ReportData>, TryRecvError>; fn wait_report(&self, duration: Duration); fn terminate_search(&mut self); }

A trait for executing consecutive searches in different starting positions.

Chess programs must rely on some type of search in order to play reasonably. Searching involves looking ahead at different move sequences and evaluating the positions after making the moves. Normally, this is done by traversing and min-maxing a tree-like data-structure by some algorithm. To implement your own search algorithm, you must define a type that implements the SearchExecutor trait.

There are two types of searches that should be distinguished:

  • Depth-first search.

    Starts at the root and explores as far as possible along each branch before backtracking.

  • Iterative deepening search.

    A depth-first search is executed with a depth of one ply, then the depth is incremented and another search is executed. This process is repeated until the search is terminated or the requested search depth is reached. In case of a terminated search, the engine can always fall back to the move selected in the last iteration of the search.

    You can use stock::Deepening to turn a depth-first searcher into a deepening searcher.

Here is what the engine does on each move:

  1. Calls start_search.

  2. Continues calling wait_report and try_recv_report periodically, until the returned report indicates that the search is done.

  3. Obtains the principal variation(s) from search reports, or directly from the transposition table.

Associated Types

The type of transposition (hash) table that the implementation works with.

The type of search node that the implementation works with.

The type of auxiliary data that search progress reports carry.

Required Methods

Creates a new instance.

Starts a new search.

  • params describes the new search.

  • time gives the remaining time on the clocks, which is useful when the search executor wants to implement its own time management logic. Otherwise, it can be ignored. None indicates that there are no time restrictions.

After calling start_search, wait_report and try_recv_report will be called periodically until the returned report indicates that the search is done. A new search will not be started until the previous search is done.

Important note: The executing search must send periodic reports, informing about its current progress. Also, the executing search must continuously update the transposition table so that, at each moment, it contains the results of the work done so far.

Attempts to return a search progress report without blocking.

Waits until a search progress report is available, timing out after a specified duration or earlier.

Requests the termination of the current search.

Can be called more than once for the same search. After calling terminate_search, wait_report and try_recv_report will continue to be called periodically until the returned report indicates that the search is done.

Implementors