Faile 1.4.4 Bug?

Discussion of chess software programming and technical issues.

Moderators: hgm, Dann Corbit, Harvey Williamson

Forum rules
This textbox is used to restore diagrams posted with the [d] tag before the upgrade.
Post Reply
outAtime
Posts: 226
Joined: Sun Mar 08, 2009 2:08 pm
Location: Canada

Faile 1.4.4 Bug?

Post by outAtime » Fri Jun 10, 2011 7:59 am

I noticed when commenting out the *update pv* portions in Faile (in root_search, search and also q_search) and trying to get a pv output purely from hash there was either no output or only one move at each depth as a pv.

1.4.4 Search:

Code: Select all

/* check our current score vs. alpha: */
    if (score > alpha && legal_move) {
      
      /* update the history heuristic since we have a cutoff: */
      history_h[moves[i].from][moves[i].target] += depth;

      /* try for an early cutoff: */
      if (score >= beta) {
	u_killers (moves[i], score);
	store_hash (i_alpha, depth, score, l_bound, moves[i]);
	return beta;
      }
      alpha = score;

      /* update the pv: */
      pv[ply][ply] = moves[i];
      for &#40;j = ply+1; j < pv_length&#91;ply+1&#93;; j++)
	pv&#91;ply&#93;&#91;j&#93; = pv&#91;ply+1&#93;&#91;j&#93;;
      pv_length&#91;ply&#93; = pv_length&#91;ply+1&#93;;
    &#125;

  &#125;

  /* check for mate / stalemate&#58; */
  if &#40;no_moves&#41; &#123;
    if &#40;in_check ()) &#123;
      alpha = -INF+ply;
    &#125;
    else &#123;
      alpha = 0;
    &#125;
  &#125;
  else &#123;
    /* check the 50 move rule if no mate situation is on the board&#58; */
    if &#40;fifty > 100&#41; &#123;
      return 0;
    &#125;
  &#125;

  /* store our hash info&#58; */
  if &#40;alpha > i_alpha&#41;
    store_hash &#40;i_alpha, depth, alpha, exact, pv&#91;ply&#93;&#91;ply&#93;);
  else
    store_hash &#40;i_alpha, depth, alpha, u_bound, dummy&#41;;

  return alpha;

&#125;
When I change it to this: I get full PV without using (commented out) Update PV anywhere (root, search, q_search).

Code: Select all

if &#40;score >= beta&#41; &#123; <--- moved to top for pv < beta purposes... 

				if &#40;moves&#91;i&#93;.captured == npiece&#41; &#123;
					/* update killer and history heuristics for non-captures */
					u_killers&#40;moves&#91;i&#93;, score&#41;;
					history_h&#91;moves&#91;i&#93;.from&#93;&#91;moves&#91;i&#93;.target&#93; += 1 << depth;
				&#125;

				store_hash&#40;i_alpha, depth, beta, l_bound, moves&#91;i&#93;);
				return beta;
			&#125;
       		
        if &#40;score > best_score && legal_move&#41; &#123; <----- change - &#40;long int best_score &#40;best_score = score = -inf;) 
		best_score = score;
		best_move = moves&#91;i&#93;; <----- at top of search - &#40;move_s best_move = dummy&#41;
		/* check our current score vs. alpha&#58; */
		if &#40;score > alpha && legal_move&#41; &#123;
			/* try for an early cutoff&#58; */
			
			alpha = score;

			/* update the pv&#58; <--------- commented out for testing!!
			pv&#91;ply&#93;&#91;ply&#93; = moves&#91;i&#93;;
			for &#40;j = ply + 1; j < pv_length&#91;ply + 1&#93;; j++)
				pv&#91;ply&#93;&#91;j&#93; = pv&#91;ply + 1&#93;&#91;j&#93;;
			pv_length&#91;ply&#93; = pv_length&#91;ply + 1&#93;;*/
			&#125;
		&#125;

	&#125;

	/* check for mate / stalemate&#58; */
	if &#40;no_moves&#41; &#123;
		if &#40;in_check&#40;)) &#123;
			alpha = -INF + ply;
		&#125; else &#123;
			alpha = 0;
		&#125;
	&#125; else &#123;
		/* check the 50 move rule if no mate situation is on the board&#58; */
		if &#40;fifty > 100&#41; &#123;
			return 0;
		&#125;
	&#125;

	/* store our hash info&#58; */ <--- changes here as well 
	if &#40;alpha <= i_alpha&#41;
		store_hash&#40;i_alpha, depth, best_score, u_bound, best_move&#41;;
	else
	    store_hash&#40;i_alpha, depth, best_score, exact, best_move&#41;;
		

	return alpha;

&#125;
Using the code above (not perfect) I can get a PV strictly from hash, the code contained in the source at:
http://sourceforge.net/projects/faile/
does not. Could anyone please confirm this strictly by reading the code I posted or by trying the test themselves? I thought I should bring it up in case anyone is trying to learn from this well commented and relatively simple source. Thanks!
outAtime

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

Re: Faile 1.4.4 Bug?

Post by outAtime » Fri Jun 10, 2011 8:12 am

P.S.

Hash to PV is in Iterative Deepening (think()) :

Code: Select all

if &#40;i_depth > 1 && abs&#40;cur_score&#41; < &#40;INF - 100&#41; && 
			    result != stalemate && result != draw_by_fifty && result != draw_by_rep&#41;
				hash_to_pv&#40;i_depth&#41;;
Thanks again.
outAtime

Post Reply