What's Strelka's Secret Sauce?

Discussion of chess software programming and technical issues.

Moderator: Ras

Uri Blass
Posts: 10793
Joined: Thu Mar 09, 2006 12:37 am
Location: Tel-Aviv Israel

Re: What's Strelka's Secret Sauce?

Post by Uri Blass »

Steve Maughan wrote:Uri,
Uri Blass wrote:1)if the evaluation is smaller than beta-125 and depth=1
goto qsearch
2)if the evaluation is smaller than beta-300 and depth<=3
goto qsearch.
Interesting. Are you sure it's beta-xxxx and not alpha-xxxx? Using beta-xxxx you can drop to the qsearch in the PV. Maybe that's what's happening but it seems a little odd.

Steve
It is done only in nodes when beta=alpha+1 and practically there is no alpha in the relevant function.

There is a special function for the case beta>alpha+1 and in this case that pruning is not done.

Uri
wgarvin
Posts: 838
Joined: Thu Jul 05, 2007 5:03 pm
Location: British Columbia, Canada

Re: What's Strelka's Secret Sauce?

Post by wgarvin »

This sounds a lot like limited razoring/AEL pruning as used by DarkThought... is my memory faulty?

http://people.csail.mit.edu/heinz/node1.html
mjlef
Posts: 1494
Joined: Thu Mar 30, 2006 2:08 pm

Re: What's Strelka's Secret Sauce?

Post by mjlef »

the devil is in the detail And it is not just going to a regula qsearch either.
Guetti

Re: What's Strelka's Secret Sauce?

Post by Guetti »

I have to admit I became curious and had a look at the qsearch.
From looking at it, I had the impression that Strelka uses pseudo-legal move generation Crafty-style. Correct?
I have to say, I like the readability of the code. However, some stuff is to complex for me. i.e. What does the following code from qsearch achieve? It is some kind of delta pruning, but I dont understand it.

Code: Select all

else if (pos_info_entry->value < (alpha - 250)) {
    // delta pruning: если оценка позиции хуже alpha,
    // то из взятий убираем "слабые" взятия через маски mask_w и mask_b
    best_value = pos_info_entry->value + 250;
    mask_w ^= Board->mp[WhitePawn];
    mask_b ^= Board->mp[BlackPawn];
    // В оригинальной версии Стрелки исключались только взятия пешек
    // Следующие исключения - Белка 1.8.12 (+13 пунктов !!!)
    if (pos_info_entry->value < (alpha - 450)) {
      best_value = pos_info_entry->value + 450;
      mask_w ^= Board->mp[WhiteKnight];
      mask_b ^= Board->mp[BlackKnight];
      mask_w ^= Board->mp[WhiteBishop];
      mask_b ^= Board->mp[BlackBishop];
      if (pos_info_entry->value < (alpha - 650)) {
        best_value = pos_info_entry->value + 650;
        mask_w ^= Board->mp[WhiteRook];
        mask_b ^= Board->mp[BlackRook];
        if (pos_info_entry->value < (alpha - 1050)) {
          best_value = pos_info_entry->value + 1050;
          mask_w ^= Board->mp[WhiteQueen];
          mask_b ^= Board->mp[BlackQueen];
        }
      }
    }
  }
Any suggestions?
Gerd Isenberg
Posts: 2251
Joined: Wed Mar 08, 2006 8:47 pm
Location: Hattingen, Germany

Re: What's Strelka's Secret Sauce?

Post by Gerd Isenberg »

Guetti wrote:I have to admit I became curious and had a look at the qsearch.
From looking at it, I had the impression that Strelka uses pseudo-legal move generation Crafty-style. Correct?
I have to say, I like the readability of the code. However, some stuff is to complex for me. i.e. What does the following code from qsearch achieve? It is some kind of delta pruning, but I dont understand it.

Code: Select all

else if (pos_info_entry->value < (alpha - 250)) {
    // delta pruning: если оценка позиции хуже alpha,
    // то из взятий убираем "слабые" взятия через маски mask_w и mask_b
    best_value = pos_info_entry->value + 250;
    mask_w ^= Board->mp[WhitePawn];
    mask_b ^= Board->mp[BlackPawn];
    // В оригинальной версии Стрелки исключались только взятия пешек
    // Следующие исключения - Белка 1.8.12 (+13 пунктов !!!)
    if (pos_info_entry->value < (alpha - 450)) {
      best_value = pos_info_entry->value + 450;
      mask_w ^= Board->mp[WhiteKnight];
      mask_b ^= Board->mp[BlackKnight];
      mask_w ^= Board->mp[WhiteBishop];
      mask_b ^= Board->mp[BlackBishop];
      if (pos_info_entry->value < (alpha - 650)) {
        best_value = pos_info_entry->value + 650;
        mask_w ^= Board->mp[WhiteRook];
        mask_b ^= Board->mp[BlackRook];
        if (pos_info_entry->value < (alpha - 1050)) {
          best_value = pos_info_entry->value + 1050;
          mask_w ^= Board->mp[WhiteQueen];
          mask_b ^= Board->mp[BlackQueen];
        }
      }
    }
  }
Any suggestions?
That is common stuff. Simply exclude pieces not worth to capture from the target-set for capture-generation - they are pruned anyway. I don't understand why it is applied for both sides though. mask_b seems only used if white to move, otherwise mask_w if black to move. Both in gen_checks and gen_captures.
mjlef
Posts: 1494
Joined: Thu Mar 30, 2006 2:08 pm

Re: What's Strelka's Secret Sauce?

Post by mjlef »

Guetti wrote:I have to admit I became curious and had a look at the qsearch.
From looking at it, I had the impression that Strelka uses pseudo-legal move generation Crafty-style. Correct?
I have to say, I like the readability of the code. However, some stuff is to complex for me. i.e. What does the following code from qsearch achieve? It is some kind of delta pruning, but I dont understand it.

Code: Select all

else if (pos_info_entry->value < (alpha - 250)) {
    // delta pruning: если оценка позиции хуже alpha,
    // то из взятий убираем "слабые" взятия через маски mask_w и mask_b
    best_value = pos_info_entry->value + 250;
    mask_w ^= Board->mp[WhitePawn];
    mask_b ^= Board->mp[BlackPawn];
    // В оригинальной версии Стрелки исключались только взятия пешек
    // Следующие исключения - Белка 1.8.12 (+13 пунктов !!!)
    if (pos_info_entry->value < (alpha - 450)) {
      best_value = pos_info_entry->value + 450;
      mask_w ^= Board->mp[WhiteKnight];
      mask_b ^= Board->mp[BlackKnight];
      mask_w ^= Board->mp[WhiteBishop];
      mask_b ^= Board->mp[BlackBishop];
      if (pos_info_entry->value < (alpha - 650)) {
        best_value = pos_info_entry->value + 650;
        mask_w ^= Board->mp[WhiteRook];
        mask_b ^= Board->mp[BlackRook];
        if (pos_info_entry->value < (alpha - 1050)) {
          best_value = pos_info_entry->value + 1050;
          mask_w ^= Board->mp[WhiteQueen];
          mask_b ^= Board->mp[BlackQueen];
        }
      }
    }
  }
Any suggestions?
It looks at what is the minimal materail needed to get the score above alpha. Any piece which has too little value to increase that score gets masked off the capture bitmap. Then only captures of those peices get generated. Simple and clever. And easy with a bitmap program.

Mark
jdart
Posts: 4398
Joined: Fri Mar 10, 2006 5:23 am
Location: http://www.arasanchess.org

Re: What's Strelka's Secret Sauce?

Post by jdart »

It is similar to AEL, but AEL does depth reduction (aka razoring) and can combine that with futility pruning that compares the static eval (or in some implementations, just the material eval) with a margin that is variable based on depth.

For futility pruning Strelka does a q-search and uses the returned value to decide whether to prune or not. It uses the same fixed margin for depth 2 and 3 and a lower one for depth 1. It also does late move reductions (but not late move pruning as in Toga).

--Jon
bob
Posts: 20943
Joined: Mon Feb 27, 2006 7:30 pm
Location: Birmingham, AL

Re: What's Strelka's Secret Sauce?

Post by bob »

mjlef wrote:
Guetti wrote:I have to admit I became curious and had a look at the qsearch.
From looking at it, I had the impression that Strelka uses pseudo-legal move generation Crafty-style. Correct?
I have to say, I like the readability of the code. However, some stuff is to complex for me. i.e. What does the following code from qsearch achieve? It is some kind of delta pruning, but I dont understand it.

Code: Select all

else if (pos_info_entry->value < (alpha - 250)) {
    // delta pruning: если оценка позиции хуже alpha,
    // то из взятий убираем "слабые" взятия через маски mask_w и mask_b
    best_value = pos_info_entry->value + 250;
    mask_w ^= Board->mp[WhitePawn];
    mask_b ^= Board->mp[BlackPawn];
    // В оригинальной версии Стрелки исключались только взятия пешек
    // Следующие исключения - Белка 1.8.12 (+13 пунктов !!!)
    if (pos_info_entry->value < (alpha - 450)) {
      best_value = pos_info_entry->value + 450;
      mask_w ^= Board->mp[WhiteKnight];
      mask_b ^= Board->mp[BlackKnight];
      mask_w ^= Board->mp[WhiteBishop];
      mask_b ^= Board->mp[BlackBishop];
      if (pos_info_entry->value < (alpha - 650)) {
        best_value = pos_info_entry->value + 650;
        mask_w ^= Board->mp[WhiteRook];
        mask_b ^= Board->mp[BlackRook];
        if (pos_info_entry->value < (alpha - 1050)) {
          best_value = pos_info_entry->value + 1050;
          mask_w ^= Board->mp[WhiteQueen];
          mask_b ^= Board->mp[BlackQueen];
        }
      }
    }
  }
Any suggestions?
It looks at what is the minimal materail needed to get the score above alpha. Any piece which has too little value to increase that score gets masked off the capture bitmap. Then only captures of those peices get generated. Simple and clever. And easy with a bitmap program.

Mark
That would seem to have a significant hole, in that sometimes removing a knight can raise the score beyond the value of a queen, assuming (say) that the knight being captured is the last opponent piece so that your passer is now free to run...
Uri Blass
Posts: 10793
Joined: Thu Mar 09, 2006 12:37 am
Location: Tel-Aviv Israel

Re: What's Strelka's Secret Sauce?

Post by Uri Blass »

bob wrote:
mjlef wrote:
Guetti wrote:I have to admit I became curious and had a look at the qsearch.
From looking at it, I had the impression that Strelka uses pseudo-legal move generation Crafty-style. Correct?
I have to say, I like the readability of the code. However, some stuff is to complex for me. i.e. What does the following code from qsearch achieve? It is some kind of delta pruning, but I dont understand it.

Code: Select all

else if (pos_info_entry->value < (alpha - 250)) {
    // delta pruning: если оценка позиции хуже alpha,
    // то из взятий убираем "слабые" взятия через маски mask_w и mask_b
    best_value = pos_info_entry->value + 250;
    mask_w ^= Board->mp[WhitePawn];
    mask_b ^= Board->mp[BlackPawn];
    // В оригинальной версии Стрелки исключались только взятия пешек
    // Следующие исключения - Белка 1.8.12 (+13 пунктов !!!)
    if (pos_info_entry->value < (alpha - 450)) {
      best_value = pos_info_entry->value + 450;
      mask_w ^= Board->mp[WhiteKnight];
      mask_b ^= Board->mp[BlackKnight];
      mask_w ^= Board->mp[WhiteBishop];
      mask_b ^= Board->mp[BlackBishop];
      if (pos_info_entry->value < (alpha - 650)) {
        best_value = pos_info_entry->value + 650;
        mask_w ^= Board->mp[WhiteRook];
        mask_b ^= Board->mp[BlackRook];
        if (pos_info_entry->value < (alpha - 1050)) {
          best_value = pos_info_entry->value + 1050;
          mask_w ^= Board->mp[WhiteQueen];
          mask_b ^= Board->mp[BlackQueen];
        }
      }
    }
  }
Any suggestions?
It looks at what is the minimal materail needed to get the score above alpha. Any piece which has too little value to increase that score gets masked off the capture bitmap. Then only captures of those peices get generated. Simple and clever. And easy with a bitmap program.

Mark
That would seem to have a significant hole, in that sometimes removing a knight can raise the score beyond the value of a queen, assuming (say) that the knight being captured is the last opponent piece so that your passer is now free to run...
This is not a significant hole because the importance of knowledge of unstoppable passed pawns when the opponent has no pieces is very small
and it even does not mean throwing that knowledge but only that you may see unstoppable pawns later in the search.

Uri
bob
Posts: 20943
Joined: Mon Feb 27, 2006 7:30 pm
Location: Birmingham, AL

Re: What's Strelka's Secret Sauce?

Post by bob »

Uri Blass wrote:
bob wrote:
mjlef wrote:
Guetti wrote:I have to admit I became curious and had a look at the qsearch.
From looking at it, I had the impression that Strelka uses pseudo-legal move generation Crafty-style. Correct?
I have to say, I like the readability of the code. However, some stuff is to complex for me. i.e. What does the following code from qsearch achieve? It is some kind of delta pruning, but I dont understand it.

Code: Select all

else if (pos_info_entry->value < (alpha - 250)) {
    // delta pruning: если оценка позиции хуже alpha,
    // то из взятий убираем "слабые" взятия через маски mask_w и mask_b
    best_value = pos_info_entry->value + 250;
    mask_w ^= Board->mp[WhitePawn];
    mask_b ^= Board->mp[BlackPawn];
    // В оригинальной версии Стрелки исключались только взятия пешек
    // Следующие исключения - Белка 1.8.12 (+13 пунктов !!!)
    if (pos_info_entry->value < (alpha - 450)) {
      best_value = pos_info_entry->value + 450;
      mask_w ^= Board->mp[WhiteKnight];
      mask_b ^= Board->mp[BlackKnight];
      mask_w ^= Board->mp[WhiteBishop];
      mask_b ^= Board->mp[BlackBishop];
      if (pos_info_entry->value < (alpha - 650)) {
        best_value = pos_info_entry->value + 650;
        mask_w ^= Board->mp[WhiteRook];
        mask_b ^= Board->mp[BlackRook];
        if (pos_info_entry->value < (alpha - 1050)) {
          best_value = pos_info_entry->value + 1050;
          mask_w ^= Board->mp[WhiteQueen];
          mask_b ^= Board->mp[BlackQueen];
        }
      }
    }
  }
Any suggestions?
It looks at what is the minimal materail needed to get the score above alpha. Any piece which has too little value to increase that score gets masked off the capture bitmap. Then only captures of those peices get generated. Simple and clever. And easy with a bitmap program.

Mark
That would seem to have a significant hole, in that sometimes removing a knight can raise the score beyond the value of a queen, assuming (say) that the knight being captured is the last opponent piece so that your passer is now free to run...
This is not a significant hole because the importance of knowledge of unstoppable passed pawns when the opponent has no pieces is very small
and it even does not mean throwing that knowledge but only that you may see unstoppable pawns later in the search.

Uri
Depends on your definition of "significant". I consider _anything_ that a human opponent can exploit to be significant. And this would fall into that category. A hole here and a hole there, and before long you have nothing but "hole"...

I think every weakness has to be fixed as it is exposed...