Here's the code for the LMR part of the engine:
Code: Select all
for(int i = 0; i < moves.length(); i++)
{
Nodes++;
move.From = moves[i].From;
move.To = moves[i].To;
move.Move_Type = moves[i].Move_Type;
MakeMove(move);
int score;
bool dofullsearch = true;
if(depth > 2
&& i > 3
&& (!moves[i].isCapture))
{
score = -AlphaBeta(-(alpha + 1), -alpha, depth - 2, &line, true);
dofullsearch = score > alpha;
}
if(dofullsearch)
{
score = -AlphaBeta(-beta, -alpha, depth - 1, &line, true);
}
move.Undo_Move();
if(score >= beta)
{
TT.save(depth, beta, pline->argmove[0], Beta, Get_Current_Hash_Key());
return beta;
}
if(score > alpha)
{
pline->argmove[0] = move;
pline->score = score;
memcpy(pline->argmove + 1, line.argmove, line.cmove * sizeof(Move));
pline->cmove = line.cmove + 1;
alpha = score;
node = Exact;
}
}
Also, am I doing anything obviously wrong with LMR here?
Thanks,
David Cimbalista