Fail High nodes

Code, algorithms, languages, construction...
Post Reply
CDaley11
Posts: 42
Joined: Thu Jan 10, 2013 6:23 am
Real Name: Christian Daley

Fail High nodes

Post by CDaley11 » Mon Jan 14, 2013 2:43 am

I am having trouble getting my transposition table to work right, manly in nodes that are not exact. Here's how I've been implementing it:

Code: Select all

// In the search function

if (CURRENT_POS_IS_IN_TABLE && CURRENT_POS_WAS_SEARCHED_ENOUGH_DEPTH ) {
     if ( node.hasExactScore ) {
          temp = node.value
     } else if ( node.Failed_High ) {
          temp = -searchToDepth( depth - 1, node.value, -alpha );
     } else if ( node.Failed_Low ) {
          temp = -searchToDepth( depth - 1, -beta, node.value );
     }
}
My program is making very poor moves with this code. If I leave out checking for Fail Highs, (i.e. I only store positions in the transposition table that failed low or have an exact score) then it works fine however. Correct me if I'm wrong, but here's how I see the three types of nodes:

Exact: The node was fully searched and didn't end because of a cutoff. The value returned can be re-used without any more search necessary.
Fail_High: The node searched produced a value that was too high for the beta so the search of that node was terminated. The returned value can be used as a lower bound because we know that a re-search of this node will produce a value at least as good as this.
Fail_Low: The node searched did not ever manage to beat the given alpha score. The value returned can be used as an upper bound because a re-search of this position will never produce a value better than this one.

lucasart
Posts: 201
Joined: Mon Dec 17, 2012 1:09 pm
Contact:

Re: Fail High nodes

Post by lucasart » Mon Jan 14, 2013 6:11 am

CDaley11 wrote:

Code: Select all

if (CURRENT_POS_IS_IN_TABLE && CURRENT_POS_WAS_SEARCHED_ENOUGH_DEPTH ) {
     if ( node.hasExactScore ) {
          temp = node.value
     } else if ( node.Failed_High ) {
          temp = -searchToDepth( depth - 1, node.value, -alpha );
     } else if ( node.Failed_Low ) {
          temp = -searchToDepth( depth - 1, -beta, node.value );
     }
}
I don't understand any of this code. You only know if the search has given you a lower bound (fail high), an upper bound (failed low), or an exact score AFTER you have completed the search (I mean the move loop with recursive search() call). What are these calls to searchToDepth() when a node has failed high or low ?
- Before the move loop, you probe the Trans Table, and return if you can (TT pruning)
- After the move loop (which ends if all moves have been searched, or if you got a beta cutoff before that) you store into the TT
"Talk is cheap. Show me the code." -- Linus Torvalds.

CDaley11
Posts: 42
Joined: Thu Jan 10, 2013 6:23 am
Real Name: Christian Daley

Re: Fail High nodes

Post by CDaley11 » Mon Jan 14, 2013 7:23 am

Ohh I see that I am doing it wrong. I get what you are saying but where would I check for what type of node it is, I.e. exact, fail high, or fail low?

Post Reply