Extensions in the days of LMR?

Discussion of chess software programming and technical issues.

Moderators: hgm, Rebel, chrisw

fierz
Posts: 72
Joined: Mon Mar 07, 2016 4:41 pm
Location: Zürich, Switzerland

Extensions in the days of LMR?

Post by fierz »

Dear all,

I recently integrated LMR (or some variant of it) into my engine, with good results. My code looks like this

Code: Select all

LMR = 0; 
		if (i > LMR_N &&								// only try late moves i> 4
			iscapture[realdepth - 1] == 0 &&		// don't try on captures
			depth > LMR_MINDEPTH  &&					// only if some depth is remaining
			ischeck[realdepth - 1] == 0	&&			// not if we are moving out of a check
			ispawnpush[realdepth -1] == 0	&&		// not for passed pawn pushes 
			ispv == 0								// not for the pv
			
			// TODO: promotions have to be exempt! but this is such a rare occasion that it shouldn't matter
			) {
			// LMR candidate - check if we are in check
			if (p->sidetomove == WHITE && !(isattacked(p, p->wking, BLACK)))
				LMR = LMR_REDUCE;
			if (p->sidetomove == BLACK && !(isattacked(p, p->bking, WHITE)))
				LMR = LMR_REDUCE;
Now I wonder: since reductions are sort of inverted extensions, and LMR reduces all kinds of moves but not checks, and not captures, and not pawn pushes, do I still need these check/recapture/pawnpush extensions or not? Do you still have them?

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

Re: Extensions in the days of LMR?

Post by bob »

fierz wrote:Dear all,

I recently integrated LMR (or some variant of it) into my engine, with good results. My code looks like this

Code: Select all

LMR = 0; 
		if (i > LMR_N &&								// only try late moves i> 4
			iscapture[realdepth - 1] == 0 &&		// don't try on captures
			depth > LMR_MINDEPTH  &&					// only if some depth is remaining
			ischeck[realdepth - 1] == 0	&&			// not if we are moving out of a check
			ispawnpush[realdepth -1] == 0	&&		// not for passed pawn pushes 
			ispv == 0								// not for the pv
			
			// TODO: promotions have to be exempt! but this is such a rare occasion that it shouldn't matter
			) {
			// LMR candidate - check if we are in check
			if (p->sidetomove == WHITE && !(isattacked(p, p->wking, BLACK)))
				LMR = LMR_REDUCE;
			if (p->sidetomove == BLACK && !(isattacked(p, p->bking, WHITE)))
				LMR = LMR_REDUCE;
Now I wonder: since reductions are sort of inverted extensions, and LMR reduces all kinds of moves but not checks, and not captures, and not pawn pushes, do I still need these check/recapture/pawnpush extensions or not? Do you still have them?

cheers
Martin
I removed everything but check extensions a couple of years back. Was an Elo gain to do so. Removing check extension hurt, however... Although I found another Elo gain by not extending checks that SEE says loses material...
User avatar
hgm
Posts: 27794
Joined: Fri Mar 10, 2006 10:06 am
Location: Amsterdam
Full name: H G Muller

Re: Extensions in the days of LMR?

Post by hgm »

Would it help to extend checks and do LMR on them? I.e. only extend if they beat alpha?
jdart
Posts: 4366
Joined: Fri Mar 10, 2006 5:23 am
Location: http://www.arasanchess.org

Re: Extensions in the days of LMR?

Post by jdart »

hgm wrote:Would it help to extend checks and do LMR on them? I.e. only extend if they beat alpha?
I assume you mean, reduce losing checks? That sounds like a reasonable idea but most engines don't do that. (Mine doesn't either although it is a little hard to see why in the code .. I only reduce moves that are in the "history phase" of move generation, and check evasions have no such phase). Last I tried it was not an improvement.

--Jon
User avatar
hgm
Posts: 27794
Joined: Fri Mar 10, 2006 10:06 am
Location: Amsterdam
Full name: H G Muller

Re: Extensions in the days of LMR?

Post by hgm »

Well, you would only know they are losing after you searched them. So what I mean is reducing all checks (possibly by 0 ply), and then re-search them with an extension if they score above alpha. Just as with any LMR'ed move. Another way to describe this as applying normal LMR after you have given the extension.
bob
Posts: 20943
Joined: Mon Feb 27, 2006 7:30 pm
Location: Birmingham, AL

Re: Extensions in the days of LMR?

Post by bob »

hgm wrote:Would it help to extend checks and do LMR on them? I.e. only extend if they beat alpha?
I tried several combinations recently.

(1) no check extensions. -10 Elo in Crafty

(2) extend checks with SEE >= 0, 0 (normal)

(3) LMR unsafe checks (SEE < 0) -10 Elo

That's not to say there is not some middle ground. IE LMR still applied to SEE < 0 checks, just a smaller reduction. That's not yet been tried.
bob
Posts: 20943
Joined: Mon Feb 27, 2006 7:30 pm
Location: Birmingham, AL

Re: Extensions in the days of LMR?

Post by bob »

hgm wrote:Well, you would only know they are losing after you searched them. So what I mean is reducing all checks (possibly by 0 ply), and then re-search them with an extension if they score above alpha. Just as with any LMR'ed move. Another way to describe this as applying normal LMR after you have given the extension.
Sounds worth testing, but not something I have done...
fierz
Posts: 72
Joined: Mon Mar 07, 2016 4:41 pm
Location: Zürich, Switzerland

Re: Extensions in the days of LMR?

Post by fierz »

bob wrote: I removed everything but check extensions a couple of years back. Was an Elo gain to do so. Removing check extension hurt, however... Although I found another Elo gain by not extending checks that SEE says loses material...
Thanks for sharing. It seems to have done my engine a world of good :-)

cheers
Martin
Robert Pope
Posts: 558
Joined: Sat Mar 25, 2006 8:27 pm

Re: Extensions in the days of LMR?

Post by Robert Pope »

How big is your LMR_REDUCE? I am only using one for now. I've tried 4-5 variations of LMR and they always perform significantly worse (60-80 ELO) than my baseline without LMR.
fierz
Posts: 72
Joined: Mon Mar 07, 2016 4:41 pm
Location: Zürich, Switzerland

Re: Extensions in the days of LMR?

Post by fierz »

Dear Robert,

my LMR_REDUCE is 1 ply and it works very very well!

cheers
Martin