Disappointing LMR Results

Discussion of chess software programming and technical issues.

Moderators: hgm, Harvey Williamson, bob

Forum rules
This textbox is used to restore diagrams posted with the [d] tag before the upgrade.
theturk1234
Posts: 52
Joined: Tue Jul 12, 2016 3:28 am

Disappointing LMR Results

Post by theturk1234 » Thu Aug 04, 2016 4:33 pm

I've tried lately to add LMR to my engine, but the results are not looking good. I'm losing like 100 ELO with the changes.
Here's the code for the LMR part of the engine:

Code: Select all

for&#40;int i = 0; i < moves.length&#40;); i++)
    &#123;
        Nodes++;
        move.From = moves&#91;i&#93;.From;
        move.To = moves&#91;i&#93;.To;
        move.Move_Type = moves&#91;i&#93;.Move_Type;
        MakeMove&#40;move&#41;;
        int score;
        bool dofullsearch = true;
        if&#40;depth > 2
		   && i > 3
		   && (!moves&#91;i&#93;.isCapture&#41;)
		   &#123;
		   		score = -AlphaBeta&#40;-&#40;alpha + 1&#41;, -alpha, depth - 2, &line, true&#41;;
		   		dofullsearch = score > alpha;
		   &#125;
		  if&#40;dofullsearch&#41;
		  &#123;
			  score = -AlphaBeta&#40;-beta, -alpha, depth - 1, &line, true&#41;;
		  &#125;
        move.Undo_Move&#40;);
        if&#40;score >= beta&#41;
        &#123;
        	TT.save&#40;depth, beta, pline->argmove&#91;0&#93;, Beta, Get_Current_Hash_Key&#40;));
        	return beta;
        &#125;
        if&#40;score > alpha&#41;
        &#123;
        	pline->argmove&#91;0&#93; = move;
            pline->score = score;
            memcpy&#40;pline->argmove + 1, line.argmove, line.cmove * sizeof&#40;Move&#41;);
            pline->cmove = line.cmove + 1;
            alpha = score;
            node = Exact;
        &#125;
    &#125;
I know Stockfish tests if the current node is a PV node and does not reduce in this case. How do I determine if the current node is a PV node?
Also, am I doing anything obviously wrong with LMR here?

Thanks,
David Cimbalista

tttony
Posts: 254
Joined: Sat Apr 23, 2011 10:33 pm
Contact:

Re: Disappointing LMR Results

Post by tttony » Thu Aug 04, 2016 5:51 pm

You are missing some important things, take a look here: https://web.archive.org/web/20150212051 ... m/lmr.html

To know the node type: https://chessprogramming.wikispaces.com/Node+Types

Also I recommend to implement some heuristic like: https://chessprogramming.wikispaces.com ... +Heuristic

smatovic
Posts: 479
Joined: Wed Mar 10, 2010 9:18 pm
Location: Germany
Contact:

Re: Disappointing LMR Results

Post by smatovic » Thu Aug 04, 2016 7:36 pm

To implement some of these conditions could help:

http://chessprogramming.wikispaces.com/ ... Conditions

--
Srdja

lauriet
Posts: 161
Joined: Sun Nov 03, 2013 8:32 am
Contact:

Re: Disappointing LMR Results

Post by lauriet » Thu Aug 04, 2016 11:02 pm

Hopefully your move ordering is correct, otherwise lmr wont work

lauriet
Posts: 161
Joined: Sun Nov 03, 2013 8:32 am
Contact:

Re: Disappointing LMR Results

Post by lauriet » Thu Aug 04, 2016 11:11 pm

Hopefully your move ordering is correct, otherwise lmr wont work

lauriet
Posts: 161
Joined: Sun Nov 03, 2013 8:32 am
Contact:

Re: Disappointing LMR Results

Post by lauriet » Thu Aug 04, 2016 11:13 pm

Hopefully your move ordering is correct, otherwise lmr wont work

Karlo Bala
Posts: 296
Joined: Wed Mar 22, 2006 9:17 am
Location: Novi Sad, Serbia

Re: Disappointing LMR Results

Post by Karlo Bala » Thu Aug 04, 2016 11:34 pm

lauriet wrote:Hopefully your move ordering is correct, otherwise lmr wont work
LMR works even with randomly sorted move list.
Best Regards,
Karlo Balla Jr.

Karlo Bala
Posts: 296
Joined: Wed Mar 22, 2006 9:17 am
Location: Novi Sad, Serbia

Re: Disappointing LMR Results

Post by Karlo Bala » Thu Aug 04, 2016 11:45 pm

theturk1234 wrote:I've tried lately to add LMR to my engine, but the results are not looking good. I'm losing like 100 ELO with the changes.
Here's the code for the LMR part of the engine:

Code: Select all

for&#40;int i = 0; i < moves.length&#40;); i++)
    &#123;
        Nodes++;
        move.From = moves&#91;i&#93;.From;
        move.To = moves&#91;i&#93;.To;
        move.Move_Type = moves&#91;i&#93;.Move_Type;
        MakeMove&#40;move&#41;;
        int score;
        bool dofullsearch = true;
        if&#40;depth > 2
		   && i > 3
		   && (!moves&#91;i&#93;.isCapture&#41;)
		   &#123;
		   		score = -AlphaBeta&#40;-&#40;alpha + 1&#41;, -alpha, depth - 2, &line, true&#41;;
		   		dofullsearch = score > alpha;
		   &#125;
		  if&#40;dofullsearch&#41;
		  &#123;
			  score = -AlphaBeta&#40;-beta, -alpha, depth - 1, &line, true&#41;;
		  &#125;
        move.Undo_Move&#40;);
        if&#40;score >= beta&#41;
        &#123;
        	TT.save&#40;depth, beta, pline->argmove&#91;0&#93;, Beta, Get_Current_Hash_Key&#40;));
        	return beta;
        &#125;
        if&#40;score > alpha&#41;
        &#123;
        	pline->argmove&#91;0&#93; = move;
            pline->score = score;
            memcpy&#40;pline->argmove + 1, line.argmove, line.cmove * sizeof&#40;Move&#41;);
            pline->cmove = line.cmove + 1;
            alpha = score;
            node = Exact;
        &#125;
    &#125;
I know Stockfish tests if the current node is a PV node and does not reduce in this case. How do I determine if the current node is a PV node?
Also, am I doing anything obviously wrong with LMR here?

Thanks,
David Cimbalista
I do not know which version of AB you are using, but re-search with an open window could be very expensive in a plain vanilla AB. Basically, average depth must be higher when using LMR. If it is not, then you have some bug.
Best Regards,
Karlo Balla Jr.

theturk1234
Posts: 52
Joined: Tue Jul 12, 2016 3:28 am

Re: Disappointing LMR Results

Post by theturk1234 » Fri Aug 05, 2016 12:58 am

Yes, my move ordering is decent at the moment, but it can use some improvement!
I was looking for that glauringchess.com page but it went offline but the link you gave works; thanks Tony!
Well, what should I do if the LMR search returns above alpha? I could try opening the window a little, but risk having to research with a full window if that search is above alpha. I just thought searching immediately with an open window was best.....

Thanks,
David

jdart
Posts: 3502
Joined: Fri Mar 10, 2006 4:23 am
Location: http://www.arasanchess.org

Re: Disappointing LMR Results

Post by jdart » Fri Aug 05, 2016 1:17 am

You can try first a zero-width search but with no reduction. Then if that still fails high, you can widen the window (again with no reduction).

LMR is highly dependent on move ordering especially if you increase the reduction with the move index. So if your move ordering is bad expect bad results from LMR.

--Jon

Post Reply