Page 1 of 1

LMR implementation

PostPosted: 08 Feb 2008, 10:11
by Manuel Peña
Can you take a look to my LMR implementation.
Sems ok?


alfabeta (int alfa,int beta,int depth,int ply,int tipe)
{
nmov=0;
...

mov(tree[i]);
nmov++;
if ((nmov>=5)&&(ply>=3)&&(!(tipe&CHECK)))
{
ev=-alfabeta(-alfa-1,-alfa,depth-2,ply+1,tipe);
if ((ev>-beta)&&(ev<-alfa)) ev=-alfabeta( -beta,-alfa,depth-1,ply+1,tipe);
}
else ev=-alfabeta(-beta,-alfa,depth-1,ply+1,tipe);
unmov();

...
}


Re: LMR implementation

PostPosted: 08 Feb 2008, 11:48
by Tord Romstad
Hello Manuel!

Manuel Peña wrote:Can you take a look to my LMR implementation.
Sems ok?


I think there is at least one important error.

alfabeta (int alfa,int beta,int depth,int ply,int tipe)
{
nmov=0;
...

mov(tree[i]);
nmov++;
if ((nmov>=5)&&(ply>=3)&&(!(tipe&CHECK)))


You should probably add some more conditions here. In particular, reducing captures is probably too dangerous. Most of us also don't reduce passed pawn pushes.

{
ev=-alfabeta(-alfa-1,-alfa,depth-2,ply+1,tipe);
if ((ev>-beta)&&(ev<-alfa)) ev=-alfabeta( -beta,-alfa,depth-1,ply+1,tipe);
}
else ev=-alfabeta(-beta,-alfa,depth-1,ply+1,tipe);
unmov();


...
}

The line with "if ((ev>-beta)&&(ev<-alfa))..." looks very strange. Comparing ev to -beta and -alfa makes no sense. I am not sure how you were thinking, but I guess you must have added an extra negation somewhere in your code.

Using "if ((ev > alfa) && (ev < beta))..." makes more sense, but is still wrong. You shouldn't allow beta cutoffs based on a reduced-depth search. I think just "if (ev > alfa)" is the correct condition to use.

Tord

Re: LMR implementation

PostPosted: 08 Feb 2008, 16:39
by Manuel Peña
Thanks Tord