Is LMR worth it ?

Discussion of chess software programming and technical issues.

Moderators: hgm, Rebel, chrisw

lauriet
Posts: 199
Joined: Sun Nov 03, 2013 9:32 am

Is LMR worth it ?

Post by lauriet »

I have a position that is mate in 5.

2rqr2k/p1pR3p/1p2Q1p1/8/3P4/3R4/PP3PPP/6K1 white to move.


If I turn off LMR my engine finds the correct move in 10 ply, and takes 36 seconds.
With LMR turned on it finds the move in 13 ply and takes 76 seconds.

One has to ask....Whats the point ?

I understand that LMR is less accurate than a full search.
Have I just found a position that demonstrates this point ?
Should I think that LMR is helpful in most positions.....but not all ?

Regrds
Laurie.
User avatar
Evert
Posts: 2929
Joined: Sat Jan 22, 2011 12:42 am
Location: NL

Re: Is LMR worth it ?

Post by Evert »

lauriet wrote: One has to ask....Whats the point ?

I understand that LMR is less accurate than a full search.
Have I just found a position that demonstrates this point ?
Should I think that LMR is helpful in most positions.....but not all ?
Exactly this. This is why you need to use games, not test positions, to measure the effectiveness of LMR.
Note that mate problems are particularly poor because often the key move is one that would be very bad in other cases and therefore a good candidate for LMR.
Ferdy
Posts: 4833
Joined: Sun Aug 10, 2008 3:15 pm
Location: Philippines

Re: Is LMR worth it ?

Post by Ferdy »

lauriet wrote:I have a position that is mate in 5.

2rqr2k/p1pR3p/1p2Q1p1/8/3P4/3R4/PP3PPP/6K1 white to move.


If I turn off LMR my engine finds the correct move in 10 ply, and takes 36 seconds.
With LMR turned on it finds the move in 13 ply and takes 76 seconds.

One has to ask....Whats the point ?

I understand that LMR is less accurate than a full search.
Have I just found a position that demonstrates this point ?
Should I think that LMR is helpful in most positions.....but not all ?

Regrds
Laurie.
Try the STS test suite, there are 1500 of them, perhaps 500ms per pos would do, and compare the results with vs without LMR.
JVMerlino
Posts: 1357
Joined: Wed Mar 08, 2006 10:15 pm
Location: San Francisco, California

Re: Is LMR worth it ?

Post by JVMerlino »

lauriet wrote:I have a position that is mate in 5.

2rqr2k/p1pR3p/1p2Q1p1/8/3P4/3R4/PP3PPP/6K1 white to move.


If I turn off LMR my engine finds the correct move in 10 ply, and takes 36 seconds.
With LMR turned on it finds the move in 13 ply and takes 76 seconds.

One has to ask....Whats the point ?

I understand that LMR is less accurate than a full search.
Have I just found a position that demonstrates this point ?
Should I think that LMR is helpful in most positions.....but not all ?

Regrds
Laurie.
[D]2rqr2k/p1pR3p/1p2Q1p1/8/3P4/3R4/PP3PPP/6K1 w

If your engine has check extensions it should find the mate very quickly, since every move from White gives check.

An engine is the sum of its parts, and sometimes one feature will perform very well when others do not. This is why test positions are not the best way to determine the strength of your engine (although they can be very beneficial to help find problem areas).

Ferdy's suggestion to use the STS suite is spot on, but I wouldn't use 500ms as your time control. That's too fast to find many of these difficult moves and the results can be discouraging. I would use 10s per move to start.

jm
User avatar
MikeB
Posts: 4889
Joined: Thu Mar 09, 2006 6:34 am
Location: Pen Argyl, Pennsylvania

Re: Is LMR worth it ?

Post by MikeB »

lauriet wrote:I have a position that is mate in 5.

2rqr2k/p1pR3p/1p2Q1p1/8/3P4/3R4/PP3PPP/6K1 white to move.


If I turn off LMR my engine finds the correct move in 10 ply, and takes 36 seconds.
With LMR turned on it finds the move in 13 ply and takes 76 seconds.

One has to ask....Whats the point ?

I understand that LMR is less accurate than a full search.
Have I just found a position that demonstrates this point ?
Should I think that LMR is helpful in most positions.....but not all ?

Regrds
Laurie.
Exclude checks from LMR and add check extension.

Code: Select all

Crafty v25.1-080416

machine has 24 processors

White(1): st 1 (search time one second)
search time set to 1.00.
White(1): noise 0
noise level set to 0.00 seconds ( show all iterations).
White(1): 2rqr2k/p1pR3p/1p2Q1p1/8/3P4/3R4/PP3PPP/6K1 w
White(1): pon off
pondering disabled.
White(1): g
        time surplus   0.00  time limit 1.00 (1.00)
        depth     time       score   variation (1)
          1     0.00/1.00     6.88   1. Rxd8 Rcxd8                 
          1->   0.00/1.00     6.88   1. Rxd8 Rcxd8                 
          2     0.00/1.00     6.88   1. Rxd8 Rcxd8                 
          2->   0.00/1.00     6.88   1. Rxd8 Rcxd8                 
          3     0.00/1.00     6.74   1. Rxd8 Rcxd8 2. Qf6+ Kg8     
          3->   0.00/1.00     6.74   1. Rxd8 Rcxd8 2. Qf6+ Kg8     
          4     0.00/1.00     6.96   1. Rxd8 Rcxd8 2. Qf6+ Kg8 3. Re3 Rxe3
                                     4. fxe3
          4->   0.00/1.00     6.96   1. Rxd8 Rcxd8 2. Qf6+ Kg8 3. Re3 Rxe3
                                     4. fxe3
          5     0.00/1.00     7.14   1. Rxd8 Rcxd8 2. Qf6+ Kg8 3. Re3 c5
                                     4. dxc5 bxc5
          5->   0.01/1.00     7.14   1. Rxd8 Rcxd8 2. Qf6+ Kg8 3. Re3 c5
                                     4. dxc5 bxc5
          6     0.01/1.00     6.87   1. Rxd8 Rcxd8 2. Qf6+ Kg8 3. Re3 c5 4. d5
                                     Rxe3 5. Qxd8+
          6     0.01/1.00    Mat05   1. Rxh7+ Kxh7 2. Qf7+ Kh6 3. Rh3+ Kg5
                                     4. Rg3+ Kh4 5. Qh7#
          6->   0.01/1.00    Mat05   1. Rxh7+ Kxh7 2. Qf7+ Kh6 3. Rh3+ Kg5
                                     4. Rg3+ Kh4 5. Qh7#
          7     0.01/1.00    Mat05   1. Rxh7+ Kxh7 2. Qf7+ Kh6 3. Rh3+ Kg5
                                     4. Rg3+ Kh4 5. Qh7#
          7->   0.01/1.00    Mat05   1. Rxh7+ Kxh7 2. Qf7+ Kh6 3. Rh3+ Kg5
                                     4. Rg3+ Kh4 5. Qh7#
          8     0.01/1.00    Mat05   1. Rxh7+ Kxh7 2. Qf7+ Kh6 3. Rh3+ Kg5
                                     4. Rg3+ Kh4 5. Qh7#
          8->   0.01/1.00    Mat05   1. Rxh7+ Kxh7 2. Qf7+ Kh6 3. Rh3+ Kg5
                                     4. Rg3+ Kh4 5. Qh7#
          9     0.01/1.00    Mat05   1. Rxh7+ Kxh7 2. Qf7+ Kh6 3. Rh3+ Kg5
                                     4. Rg3+ Kh4 5. Qh7#
          9->   0.01/1.00    Mat05   1. Rxh7+ Kxh7 2. Qf7+ Kh6 3. Rh3+ Kg5
                                     4. Rg3+ Kh4 5. Qh7#
         10     0.01/1.00    Mat05   1. Rxh7+ Kxh7 2. Qf7+ Kh6 3. Rh3+ Kg5
                                     4. Rg3+ Kh4 5. Qh7#
         10->   0.01/1.00    Mat05   1. Rxh7+ Kxh7 2. Qf7+ Kh6 3. Rh3+ Kg5
                                     4. Rg3+ Kh4 5. Qh7#
         11     0.01/1.00    Mat05   1. Rxh7+ Kxh7 2. Qf7+ Kh6 3. Rh3+ Kg5
                                     4. Rg3+ Kh4 5. Qh7#
         11->   0.01/1.00    Mat05   1. Rxh7+ Kxh7 2. Qf7+ Kh6 3. Rh3+ Kg5
                                     4. Rg3+ Kh4 5. Qh7#
         12     0.01/1.00    Mat05   1. Rxh7+ Kxh7 2. Qf7+ Kh6 3. Rh3+ Kg5
                                     4. Rg3+ Kh4 5. Qh7#
         12->   0.01/1.00    Mat05   1. Rxh7+ Kxh7 2. Qf7+ Kh6 3. Rh3+ Kg5
                                     4. Rg3+ Kh4 5. Qh7#
         13     0.02/1.00    Mat05   1. Rxh7+ Kxh7 2. Qf7+ Kh6 3. Rh3+ Kg5
                                     4. Rg3+ Kh4 5. Qh7#
         13->   0.02/1.00    Mat05   1. Rxh7+ Kxh7 2. Qf7+ Kh6 3. Rh3+ Kg5
                                     4. Rg3+ Kh4 5. Qh7#
        time=0.02(100%)  nodes=70596(70.6K)  fh1=97%  pred=0  nps=3.5M
        chk=1.8K  qchk=3.5K  fp=44.2K  mcp=132  50move=1
        LMReductions:  1/1.3K  2/958  3/1.3K  4/894  5/102
        null-move (R):  3/3.5K  4/696  5/2

mate in 5 moves.

White(1): Rxh7+
              time used:   0.02
Black(1): 
brtzsnr
Posts: 433
Joined: Fri Jan 16, 2015 4:02 pm

Re: Is LMR worth it ?

Post by brtzsnr »

LMR is worth because it allows you to search deeper on promising lines and less on bad lines. Since it searches deeper the engine can find more tactical shots.

LMR cannot be measured on test positions because it depends heavily on hash moves, killer moves, checks and other moves statistics. There is little correlation between different test positions so your move order will suffer.

I use test positions only to find promising patches and validate my refactorings. I rarely commit without playing games. Even STC has issues with LMR, so sometimes I have to run games at LTC directly.
Henk
Posts: 7216
Joined: Mon May 27, 2013 10:31 am

Re: Is LMR worth it ?

Post by Henk »

Still don't know a good reduction formula for LMR. For instance is it depth dependent and why (not) ?
brtzsnr
Posts: 433
Joined: Fri Jan 16, 2015 4:02 pm

Re: Is LMR worth it ?

Post by brtzsnr »

My formula is: lmr = 1 + min(depth, numMoves)/5. Not the most advanced, but it is simple and works well so far. I think most engines use a depth dependent reduction with the idea that at higher depths you can reduce more and still have a low error rate since most tactical lines are short (capture the Queen, fork, etc).

Code: Select all

lmr := int32(0)
if allowLateMove && !givesCheck && !critical {
  if move.IsQuiet() || seeSign(pos, move) {
    // Reduce quie and bad capture moves more at high depths and after many quiet moves.
    // Large numMoves means it's likely not a CUT node.  Large depth means reductions are less risky.
    lmr = 1 + min(depth, numMoves)/5
  }
}
User avatar
cdani
Posts: 2204
Joined: Sat Jan 18, 2014 10:24 am
Location: Andorra

Re: Is LMR worth it ?

Post by cdani »

The lmr formula is something that should evolve with the engine. As the engine is better, has better eval, goes deeper, you can make it more aggressive.