Late move reductions ?

Discussion of chess software programming and technical issues.

Moderators: hgm, Rebel, chrisw

MahmoudUthman
Posts: 234
Joined: Sat Jan 17, 2015 11:54 pm

Late move reductions ?

Post by MahmoudUthman »

I tried it in non PV nodes reducing only quiet moves "castling excluded" & depth >2, using a reduction of 1 and I almost got no improvement "for example in the starting position ~-1second at depth 13 which takes ~16s without it" , I also tried it not reducing while in check and it was worse ,so am I doing something wrong ?
*Also what type of moves that should/shouldn't be reduced , and by how much "any general formula that works well generally" ?
*also in stock fish :

Code: Select all

// Step 13. Pruning at shallow depth
      if (  !rootNode
          && bestValue > VALUE_MATED_IN_MAX_PLY)
      {
          if (   !captureOrPromotion
              && !givesCheck
              && !pos.advanced_pawn_push(move))
          {
              // Move count based pruning
              if (moveCountPruning)
                  continue;

              // Reduced depth of the next LMR search
              int lmrDepth = std&#58;&#58;max&#40;newDepth - reduction<PvNode>&#40;improving, depth, moveCount&#41;, DEPTH_ZERO&#41; / ONE_PLY;

              // Countermoves based pruning
              if (   lmrDepth < 3
                  && (!cmh  || (*cmh )&#91;moved_piece&#93;&#91;to_sq&#40;move&#41;&#93; < VALUE_ZERO&#41;
                  && (!fmh  || (*fmh )&#91;moved_piece&#93;&#91;to_sq&#40;move&#41;&#93; < VALUE_ZERO&#41;
                  && (!fmh2 || (*fmh2&#41;&#91;moved_piece&#93;&#91;to_sq&#40;move&#41;&#93; < VALUE_ZERO || &#40;cmh && fmh&#41;))
                  continue;

              // Futility pruning&#58; parent node
              if (   lmrDepth < 7
                  && !inCheck
                  && ss->staticEval + 256 + 200 * lmrDepth <= alpha&#41;
                  continue;

              // Prune moves with negative SEE
              if (   lmrDepth < 8
                  && !pos.see_ge&#40;move, Value&#40;-35 * lmrDepth * lmrDepth&#41;))
                  continue;
          &#125;
          else if (    depth < 7 * ONE_PLY
                   && !extension
                   && !pos.see_ge&#40;move, -PawnValueEg * &#40;depth / ONE_PLY&#41;))
                  continue;
why is it pruning moves with bad see based on the lmr depth/depth even captures , isn't that dangerous ?
& is there any connection between futility pruning and lmr's depth, or is it just using lmr's formula for futility ?
Ferdy
Posts: 4833
Joined: Sun Aug 10, 2008 3:15 pm
Location: Philippines

Re: Late move reductions ?

Post by Ferdy »

MahmoudUthman wrote:I tried it in non PV nodes reducing only quiet moves "castling excluded" & depth >2, using a reduction of 1 and I almost got no improvement
It is fine to have a little improvement.
MahmoudUthman wrote: "for example in the starting position ~-1second at depth 13 which takes ~16s without it" , I also tried it not reducing while in check and it was worse ,so am I doing something wrong ?
Could you post sample code you use, also describe your move ordering, because LMR is dependent on it.
MahmoudUthman wrote: *Also what type of moves that should/shouldn't be reduced , and by how much "any general formula that works well generally" ?
This is engine dependent you have to test every possible way like what SF team is doing. Usually you don't reduce captures and queen promotions. But the basic concept is to examine your evaluation function. Tell me which features in your eval has bonus and penalty. Passers for example has a good bonus points, so try not to reduce passers in the search. Also try not to reduce killers and moves with good history, you can try to reduce these type of moves later as you become familiar with your engine.
MahmoudUthman wrote: *also in stock fish :

Code: Select all

// Step 13. Pruning at shallow depth
      if (  !rootNode
          && bestValue > VALUE_MATED_IN_MAX_PLY&#41;
      &#123;
          if (   !captureOrPromotion
              && !givesCheck
              && !pos.advanced_pawn_push&#40;move&#41;)
          &#123;
              // Move count based pruning
              if &#40;moveCountPruning&#41;
                  continue;

              // Reduced depth of the next LMR search
              int lmrDepth = std&#58;&#58;max&#40;newDepth - reduction<PvNode>&#40;improving, depth, moveCount&#41;, DEPTH_ZERO&#41; / ONE_PLY;

              // Countermoves based pruning
              if (   lmrDepth < 3
                  && (!cmh  || (*cmh )&#91;moved_piece&#93;&#91;to_sq&#40;move&#41;&#93; < VALUE_ZERO&#41;
                  && (!fmh  || (*fmh )&#91;moved_piece&#93;&#91;to_sq&#40;move&#41;&#93; < VALUE_ZERO&#41;
                  && (!fmh2 || (*fmh2&#41;&#91;moved_piece&#93;&#91;to_sq&#40;move&#41;&#93; < VALUE_ZERO || &#40;cmh && fmh&#41;))
                  continue;

              // Futility pruning&#58; parent node
              if (   lmrDepth < 7
                  && !inCheck
                  && ss->staticEval + 256 + 200 * lmrDepth <= alpha&#41;
                  continue;

              // Prune moves with negative SEE
              if (   lmrDepth < 8
                  && !pos.see_ge&#40;move, Value&#40;-35 * lmrDepth * lmrDepth&#41;))
                  continue;
          &#125;
          else if (    depth < 7 * ONE_PLY
                   && !extension
                   && !pos.see_ge&#40;move, -PawnValueEg * &#40;depth / ONE_PLY&#41;))
                  continue;
why is it pruning moves with bad see based on the lmr depth/depth even captures ,
Read the code again.
User avatar
cdani
Posts: 2204
Joined: Sat Jan 18, 2014 10:24 am
Location: Andorra

Re: Late move reductions ?

Post by cdani »

MahmoudUthman wrote:... and I almost got no improvement "for example in the starting position ~-1second at depth 13 which takes ~16s without it"
I'm not sure what you mean. If you mean that your measure of improvement is how fast goes to a given depth, is not a good measure. The good measure is to play enough games to have an statistically significative result. Maybe you have done it already.
Henk
Posts: 7216
Joined: Mon May 27, 2013 10:31 am

Re: Late move reductions ?

Post by Henk »

LMR assumes that all late moves are bad moves. But that is almost never the case. For there are many late moves and information about move order is cumbersome.

So it's not much more than an upgraded PV extension.
Lyudmil Tsvetkov
Posts: 6052
Joined: Tue Jun 12, 2012 12:41 pm

Re: Late move reductions ?

Post by Lyudmil Tsvetkov »

Henk wrote:LMR assumes that all late moves are bad moves. But that is almost never the case. For there are many late moves and information about move order is cumbersome.

So it's not much more than an upgraded PV extension.
are not you mixing LMR with LMP? :)

or I got a sunstroke?
Henk
Posts: 7216
Joined: Mon May 27, 2013 10:31 am

Re: Late move reductions ?

Post by Henk »

Lyudmil Tsvetkov wrote:
Henk wrote:LMR assumes that all late moves are bad moves. But that is almost never the case. For there are many late moves and information about move order is cumbersome.

So it's not much more than an upgraded PV extension.
are not you mixing LMR with LMP? :)

or I got a sunstroke?


Reducing search of late moves and not seeing that at least one of them is better than current PV is bad enough.
Lyudmil Tsvetkov
Posts: 6052
Joined: Tue Jun 12, 2012 12:41 pm

Re: Late move reductions ?

Post by Lyudmil Tsvetkov »

Henk wrote:
Lyudmil Tsvetkov wrote:
Henk wrote:LMR assumes that all late moves are bad moves. But that is almost never the case. For there are many late moves and information about move order is cumbersome.

So it's not much more than an upgraded PV extension.
are not you mixing LMR with LMP? :)

or I got a sunstroke?


Reducing search of late moves and not seeing that at least one of them is better than current PV is bad enough.


I supposed you were talking about completely pruning away moves ordered lower in the list, as you were talking about move ordering. why do only a shallower search on moves ordered lower, as you can completely prune after 3rd or 4th ordered move?

in any case, what do couple of plies more or less really mean? in 3/4 of all cases you hit an evaluation position again, and not one resolved until mate/big material/positional advantage, and chances are your eval migth be better at bigger-depth nodes, but it also migth be worse there in comparison to lower-depth nodes?