My Project
Functions | Variables
root.c File Reference
#include "search.h"
#include "bit.h"
#include "options.h"
#include "stats.h"
#include "util.h"
#include "ybwc.h"
#include "settings.h"
#include <stdlib.h>
#include <assert.h>

Functions

void pv_debug (Search *search, const Move *bestmove, FILE *f)
 Debug PV. More...
 
bool is_pv_ok (Search *search, int bestmove, int search_depth)
 Check if PV is ok. More...
 
static int guess_move (Search *search, Board *board)
 Guess a move. More...
 
void record_best_move (Search *search, const Board *init_board, const Move *bestmove, const int alpha, const int beta, const int depth)
 Record best move. More...
 
void show_current_move (FILE *f, Search *search, const Move *move, const int alpha, const int beta, const bool parallel)
 
int search_bound (const Search *search, int score)
 bound root scores according to stable squares More...
 
static int search_route_PVS (Search *search, int alpha, int beta, const int depth, Node *node)
 Reroute the PVS between midgame,endgame or terminal PVS. More...
 
int search_get_pv_cost (Search *search)
 Compute a cost as a combination of node count, depth, etc. from hash_table. More...
 
int PVS_root (Search *search, const int alpha, const int beta, const int depth)
 Principal Variation Search algorithm at the root of the tree. More...
 
int aspiration_search (Search *search, int alpha, int beta, const int depth, int score)
 Aspiration window. More...
 
static bool get_last_level (Search *search, int *depth, int *selectivity)
 Retrieve the last level of the search. More...
 
void iterative_deepening (Search *search, int alpha, int beta)
 Iterative deepening. More...
 
void * search_run (void *v)
 Search the bestmove of a given board. More...
 

Variables

Log search_log [1]
 
Log engine_log [1]
 

Detailed Description

Search near the end of the game.

Date
1998 - 2017
Author
Richard Delorme
Version
4.4

Function Documentation

◆ aspiration_search()

int aspiration_search ( Search search,
int  alpha,
int  beta,
const int  depth,
int  score 
)

Aspiration window.

Parameters
searchSearch.
alphaAlpha bound.
betaBeta bound.
depthDepth.
scorePrevious score.
Returns
A score.

◆ get_last_level()

static bool get_last_level ( Search search,
int *  depth,
int *  selectivity 
)
static

Retrieve the last level of the search.

Parameters
searchSearch.
depthDepth of the last search.
selectivitySelectivity of the last search.

◆ guess_move()

static int guess_move ( Search search,
Board board 
)
static

Guess a move.

this function is used when no move is found in the position retrieved from the hash table, meaning a fail-low search without a good move happened. A move is guessed after a "shallow search".

Parameters
searchSearch.
boardBoard to guess move from.
Returns
a best move guessed from a shallow search (depth = 4).

◆ is_pv_ok()

bool is_pv_ok ( Search search,
int  bestmove,
int  search_depth 
)

Check if PV is ok.

Parameters
searchSearch.
bestmoveBest move.
search_depthDepth.
Returns
true if PV is ok.

◆ iterative_deepening()

void iterative_deepening ( Search search,
int  alpha,
int  beta 
)

Iterative deepening.

Search the current position at increasing depths, and once full depth (equaling the number of empties) has been reached at decreasing selectivity ; until the position is eventually solved.

Parameters
searchSearch.
alphaAlpha bound.
betaBeta bound.

◆ pv_debug()

void pv_debug ( Search search,
const Move bestmove,
FILE *  f 
)

Debug PV.

Parameters
searchSearch.
bestmoveBest move.
fOutput stream.

◆ PVS_root()

int PVS_root ( Search search,
const int  alpha,
const int  beta,
const int  depth 
)

Principal Variation Search algorithm at the root of the tree.

this function solves the position provided within the limits set by the alpha and beta bounds. The movelist parameter is updated so that the bestmove is the first of the list when the search ended.

Parameters
searchSearch.
alphaAlpha bound.
betaBeta bound.
depthRemaining depth.
Returns
A score, as a disc difference.

◆ record_best_move()

void record_best_move ( Search search,
const Board init_board,
const Move bestmove,
const int  alpha,
const int  beta,
const int  depth 
)

Record best move.

Parameters
searchSearch.
init_boardInitial board.
bestmoveBest move.
alphaAlpha Bound.
betaBeta Bound.
depthDepth.

◆ search_bound()

int search_bound ( const Search search,
int  score 
)

bound root scores according to stable squares

Parameters
searchPosition to search.
scorescore to bound.
Returns
score;

◆ search_get_pv_cost()

int search_get_pv_cost ( Search search)

Compute a cost as a combination of node count, depth, etc. from hash_table.

The board is supposed to be updated by a move after the root position.

Parameters
searchSearch.
Returns
A search cost.

◆ search_route_PVS()

static int search_route_PVS ( Search search,
int  alpha,
int  beta,
const int  depth,
Node node 
)
static

Reroute the PVS between midgame,endgame or terminal PVS.

Parameters
searchSearch.
alphaAlpha bound.
betaBeta bound.
depthDepth.
nodeNode position.
Returns
A score, as a disc difference.

◆ search_run()

void * search_run ( void *  v)

Search the bestmove of a given board.

this is a function runable within its own thread. The board is supposed to have been set (by search_set_board()), and all search options (level, time, etc.) too. this function proceeds to some internal initialisations and then call the iterative deepening function, from where the search is actually done. After the search ends, some finalizations are done before the function returns.

Parameters
vSearch cast as void.
Returns
The search result.

◆ show_current_move()

void show_current_move ( FILE *  f,
Search search,
const Move move,
const int  alpha,
const int  beta,
const bool  parallel 
)

Variable Documentation

◆ engine_log

Log engine_log[1]
extern

◆ search_log

Log search_log[1]
extern