question about search depth

Discussion of chess software programming and technical issues.

Moderator: Ras

cyberfish

Re: question about search depth

Post by cyberfish »

You should take cutoffs if thisScore >= upperBound (or <= loweBound), not just > or <. This might ause you to mess many cutoffs. It is difficult to judge how bad this is; it depends on the finess of your evaluation.
*wiping tears* that was it. It's what I have being looking for for the last two weeks. Thank you very much. Now it can do 7-ply full width on that same position in 44 seconds.

Code: Select all

---
0       10      0       295     c8g4 
Branching factor: 0.001074
ABnodes: 0 Qnodes: 295. 274674 NPS. Num cutoffs: 174.
---
---
1       6       0       873     c8g4 c1e3 g4f3 g2f3 
Branching factor: 2.62568
ABnodes: 47 Qnodes: 826. 309577 NPS. Num cutoffs: 458.
---
---
2       16      3       5069    c8g4 d4e5 g4f3 g2f3 d5e5 
Branching factor: 10.5029
ABnodes: 241 Qnodes: 4828. 171145 NPS. Num cutoffs: 3134.
---
---
3       6       7       24114   c8g4 c1e3 g4f3 g2f3 
Branching factor: 1.22713
ABnodes: 2903 Qnodes: 21211. 663474 NPS. Num cutoffs: 12881.
---
---
4       16      27      185282  c8g4 d4e5 g4f3 g2f3 d5e5 
Branching factor: 5.71943
ABnodes: 12213 Qnodes: 173069. 891323 NPS. Num cutoffs: 98422.
---
---
5       10      130     806040  c8g4 d4e5 g4f3 d1f3 d5e5 f1e2 
Branching factor: 4.95884
ABnodes: 109607 Qnodes: 696433. 781949 NPS. Num cutoffs: 386166.
---
---
6       14      838     6657838 e5d4 d1d4 d5e6 f3e5 b8c6 f1b5 g8f6 b5c6 b7c6 
Branching factor: 6.86328
ABnodes: 467079 Qnodes: 6190759. 941073 NPS. Num cutoffs: 2925626.
---
---
7       10      4391    28967711        c8g4 d4e5 g4f3 d1f3 d5e5 f1e2 b8c6 b1c3 
Branching factor: 5.02189
ABnodes: 3988543 Qnodes: 24979168. 815338 NPS. Num cutoffs: 12796660.
---
Thanks again to you all.
Tony

Re: question about search depth

Post by Tony »

I think you forgot a bit of code:

something like

Code: Select all


if (depth<=0 && 
   ((moving_side == engine_side && staticScore>=beta)
   || (moving_side != engine_side && staticScore<=alpha)))
        return(staticScore)
Put this before you try the moves.

As you don't have this know, the engine has to try all the moves first before it can see that the score was already a cutoff.

It could explain the QSearch explosion.

BTW you might wanna change your code to the negamax variation. It's a lot more compact and (for most of us) more readable.

Tony
cyberfish

Re: question about search depth

Post by cyberfish »

Thanks for the reply.
I think you forgot a bit of code:

something like

Code: Select all

if (depth<=0 &&
   ((moving_side == engine_side && staticScore>=beta)
   || (moving_side != engine_side && staticScore<=alpha)))
        return(staticScore) 
I think I do have that, disguised in all the messiness.

Code: Select all

Score staticScore = staticEval();

   if (depth <= 0) {
      if (moving_side == engine_side) { //maximize
         if (staticScore > higherBound) {
            Cutoffcount++;
            delete pseudoMoves;
            recordEntry(depth, AT_LEAST, staticScore, 0);
            return staticScore;
         }
         if (staticScore > lowerBound) {
            lowerBound = staticScore;
         }
      } else { //minimize
         if (staticScore < lowerBound) {
            Cutoffcount++;
            delete pseudoMoves;
            recordEntry(depth, AT_MOST, staticScore, 0);
            return staticScore;
         }
         if (staticScore < higherBound) {
            higherBound = staticScore;
         }
      }
   }
BTW you might wanna change your code to the negamax variation. It's a lot more compact and (for most of us) more readable.
I will probably change it after I become more familiar with chess programming. This is my first try in chess programming, that is why I try to keep everything more apparently logical (to me). Thanks for the suggestion though.
Tony

Re: question about search depth

Post by Tony »

cyberfish wrote:Thanks for the reply.
I think you forgot a bit of code:

something like

Code: Select all

if (depth<=0 &&
   ((moving_side == engine_side && staticScore>=beta)
   || (moving_side != engine_side && staticScore<=alpha)))
        return(staticScore) 
I think I do have that, disguised in all the messiness.

Code: Select all

Score staticScore = staticEval();

   if (depth <= 0) {
      if (moving_side == engine_side) { //maximize
         if (staticScore > higherBound) {
            Cutoffcount++;
            delete pseudoMoves;
            recordEntry(depth, AT_LEAST, staticScore, 0);
            return staticScore;
         }
         if (staticScore > lowerBound) {
            lowerBound = staticScore;
         }
      } else { //minimize
         if (staticScore < lowerBound) {
            Cutoffcount++;
            delete pseudoMoves;
            recordEntry(depth, AT_MOST, staticScore, 0);
            return staticScore;
         }
         if (staticScore < higherBound) {
            higherBound = staticScore;
         }
      }
   }
Ah yes, I see the code is doubled. It is much more efficient to move this part of the code above the movegeneration and the hashtableprobe.

Tony
PK
Posts: 905
Joined: Mon Jan 15, 2007 11:23 am
Location: Warsza

Re: question about search depth

Post by PK »

BTW, what is a normal proportion between quiescence nodes and normal nodes? Right now my engine spends something like 70-80% in the quiescent search, and I'm worried that it's rather on the high side.

Or is it just that when more hashing, futility prunning and similar stuff is added, then relatively more time is spend on searching captures? (befoire a rewriter I had a version where the ratio was about 50%).

regards,

Pawel Koziol
cyberfish

Re: question about search depth

Post by cyberfish »

Ah yes, I see the code is doubled. It is much more efficient to move this part of the code above the movegeneration and the hashtableprobe.
Hmm, that makes sense. Thanks for the suggestion.
BTW, what is a normal proportion between quiescence nodes and normal nodes? Right now my engine spends something like 70-80% in the quiescent search, and I'm worried that it's rather on the high side.
Sorry I have no idea what the ratio should be either. As you can see I am a beginner in chess programming, too. My engine spends something like 90% in Qsearch on the 7th ply or so.
Harald Johnsen

Re: question about search depth

Post by Harald Johnsen »

You can reduce this number a lot by :
- not making captures that can not put you at the alpha/beta score (futility pruning)
- stoping the search at the first capture with negative see.

Of course you do less QS too if you have some futility pruning in the main search (frontier, pre-frontier,razoring).

HJ.