Just prepending the best move as a duplicat, an relying on a hash hit
to skip searching the later occurrence, is not satisfactory in multi-PV
mode, as moves with the same score would both output a PV. We now erase
the original move (by setting it to the invalid 0), an skip such moves
in the move loop.
}
}
- if(ply == 0 && moveMap[moveStack[curMove] & 0xFFFF]) continue; // excluded root move
+ if(!moveStack[curMove] || ply == 0 && moveMap[moveStack[curMove] & 0xFFFF]) continue; // erased, or excluded root move
// make move
if(MakeMove(&f, moveStack[curMove])) { // aborts if fails to evade existing check
// put best in front
if(bestNr > m.firstMove) {
int bestMove = moveStack[bestNr];
- if(bestNr == m.firstMove+1) moveStack[bestNr] = moveStack[m.firstMove]; else m.firstMove--; // swap first two, or prepend duplicat
+ if(bestNr == m.firstMove+1) moveStack[bestNr] = moveStack[m.firstMove]; // swap first two
+ else m.firstMove--, moveStack[bestNr] = 0; // or prepend and erase in original location
moveStack[bestNr = m.firstMove] = bestMove;
} else m.late += (m.late == bestNr); // if best already in front (or non-existing), just make sure it is not reduced