Error in Fruit 2.1 source?

Discussion of chess software programming and technical issues.

Moderators: hgm, Rebel, chrisw

ernest
Posts: 2041
Joined: Wed Mar 08, 2006 8:30 pm

Error in Fruit 2.1 source?

Post by ernest »

A friend of mine thinks he has found an error in the Fruit 2.1 source.

This error is in the procedure trans_store() of the trans.cpp module, on the line marked with a series of ?????????.

Due to the <return>, this line, modifying entry->depth, has no effect if entry->lock != KEY_LOCK(key).
However, entry->depth is only used if entry->lock != KEY_LOCK(key).
So, the modification of entry->depth seems to be never used.

Code: Select all

void trans_store&#40;trans_t * trans, uint64 key, int move, int depth, int min_value, int max_value&#41; &#123;
   entry = trans_entry&#40;trans,key&#41;;
   for &#40;i = 0; i < ClusterSize; i++, entry++) &#123;
      if &#40;entry->lock == KEY_LOCK&#40;key&#41;) &#123;
         entry->date = trans->date;
?????????         if &#40;depth > entry->depth&#41; entry->depth = depth; // for replacement scheme
         if &#40;move != MoveNone && depth >= entry->move_depth&#41; &#123;
            entry->move_depth = depth;
            entry->move = move;
         &#125;
         if &#40;min_value > -ValueInf && depth >= entry->min_depth&#41; &#123;
            entry->min_depth = depth;
            entry->min_value = min_value;
         &#125;
         if &#40;max_value < +ValueInf && depth >= entry->max_depth&#41; &#123;
            entry->max_depth = depth;
            entry->max_value = max_value;
         &#125;
         return;
      &#125;
      // evaluate replacement score
      score = trans->age&#91;entry->date&#93; * 256 - entry->depth;
................ 
................
&#125;
Dann Corbit
Posts: 12541
Joined: Wed Mar 08, 2006 8:57 pm
Location: Redmond, WA USA

Re: Error in Fruit 2.1 source?

Post by Dann Corbit »

ernest wrote:A friend of mine thinks he has found an error in the Fruit 2.1 source.

This error is in the procedure trans_store() of the trans.cpp module, on the line marked with a series of ?????????.

Due to the <return>, this line, modifying entry->depth, has no effect if entry->lock != KEY_LOCK(key).
However, entry->depth is only used if entry->lock != KEY_LOCK(key).
So, the modification of entry->depth seems to be never used.

Code: Select all

void trans_store&#40;trans_t * trans, uint64 key, int move, int depth, int min_value, int max_value&#41; &#123;
   entry = trans_entry&#40;trans,key&#41;;
   for &#40;i = 0; i < ClusterSize; i++, entry++) &#123;
      if &#40;entry->lock == KEY_LOCK&#40;key&#41;) &#123;
         entry->date = trans->date;
?????????         if &#40;depth > entry->depth&#41; entry->depth = depth; // for replacement scheme
We are updating the value in the hash table. The next time we access the hash table, the updated value will be present.

Where we are right now:
We found a definitely matching entry in the hash table.
The entry we were passed in was deeper than the one that was stored.
Update the stored entry with the greater depth value.

Does not look like a bug to me.

Code: Select all

         if &#40;move != MoveNone && depth >= entry->move_depth&#41; &#123;
            entry->move_depth = depth;
            entry->move = move;
         &#125;
         if &#40;min_value > -ValueInf && depth >= entry->min_depth&#41; &#123;
            entry->min_depth = depth;
            entry->min_value = min_value;
         &#125;
         if &#40;max_value < +ValueInf && depth >= entry->max_depth&#41; &#123;
            entry->max_depth = depth;
            entry->max_value = max_value;
         &#125;
         return;
      &#125;
      // evaluate replacement score
      score = trans->age&#91;entry->date&#93; * 256 - entry->depth;
................ 
................
&#125;
ernest
Posts: 2041
Joined: Wed Mar 08, 2006 8:30 pm

Re: Error in Fruit 2.1 source?

Post by ernest »

Dann Corbit wrote:Does not look like a bug to me.
Thanks, Dann, of course you're right!