perft method
Perform a perft test on the current position, to depth
.
Implementation
int perft(int depth) {
if (depth < 1) return 1;
List<Move> moves = generateLegalMoves();
int nodes = 0;
for (Move m in moves) {
makeMove(m, false);
if (depth - 1 > 0) {
int childNodes = perft(depth - 1);
nodes += childNodes;
} else {
nodes++;
}
undo();
}
return nodes;
}