PV Flag

Discussion of chess software programming and technical issues.

Moderator: Ras

outAtime
Posts: 226
Joined: Sun Mar 08, 2009 3:08 pm
Location: Canada

PV Flag

Post by outAtime »

I started this new thread to ask for some help understanding when this searching_pv flag will = FALSE. Code is from Faile.

so in root_search just before searching:

Code: Select all

  searching_pv = TRUE;  

  /* generate and order moves: */
  gen (&moves[0], &num_moves);
  order_moves (&moves[0], &move_ordering[0], num_moves, &h_move);
to order_moves:

Code: Select all

    if (searching_pv) {
    searching_pv = FALSE;

     /* make the pv have highest move ordering: */
     if (from == pv[1][ply].from && target == pv[1][ply].target
	 && promoted == pv[1][ply].promoted) {
        searching_pv = TRUE;
	move_ordering[i] += INF;
   
     else {
     /* add the history heuristic bonus: */
     move_ordering[i] += (history_h[from][target]>>i_depth);
     /* add the killer move heuristic bonuses: */

      /* if not searching the pv: */
      else {
      /* give captures precedence in move ordering, and order captures by
	  material gain */
       killers...etc....
order_moves is also called by qsearch() and search(). root_search() calls search() only. search() calls search() only.

When does searching_pv = FALSE? Is it only TRUE if searching the first move at the root? Could it be false anywhere else? TRUE again later? Thanks!
outAtime
User avatar
Greg Strong
Posts: 388
Joined: Sun Dec 21, 2008 6:57 pm
Location: Washington, DC

Re: PV Flag

Post by Greg Strong »

It is likely true when walking the PV at the beginning of a new depth iteration. When the search is depened, you want to try the moves from the PV from last iteration first. So searching_pv is true at the nodes all the way down the left side of the search tree.
outAtime
Posts: 226
Joined: Sun Mar 08, 2009 3:08 pm
Location: Canada

Re: PV Flag

Post by outAtime »

Thanks! My understanding was that in a PVS search you are only searching the PV on the first move or on fail high research:

Code: Select all

at root...

if move == 1
searching PV = true
search -beta -alpha
else {
searching pv = false
search -alpha alpha
if score > alpha
searching pv = true
search -beta -alpha
So in Faile, which doesn't have PVS, the searching_PV flag is set in move_ordering:

Code: Select all

at root...

searching_pv = true
move_ordering()
make
if legal
search -beta -alpha
unmake
if score > alpha
return best_move

move_ordering()

if searching_pv {
searching_pv = false
if (from == pv[1][ply].from && target == pv[1][ply].target
     && promoted == pv[1][ply].promoted) {

searching_pv  = true

else{
other move ordering
So will the way this flag is set still work with PVS? Because Im thinking when search() is called from the root the flag will always = true the way it is now, regardless if the call is from -alpha alpha.
outAtime