At the leaves of a perft, you only want to know if a move is legal or not:
Code: Select all
if (move_is_legal) perft_count++;Code: Select all
make_move(move);
if (king_not_in_check) perft_count++:
unmake_move(move);When you perform an alpha-beta search, it is entirely different. What you want is:
Code: Select all
if (move_is_legal) {
make_move(move);
...
unmake_move(move);
}Code: Select all
make_move(move);
if (king_not_in_check) {
...
}
unmake_move();For perft you don't need to work hard at all to win time using a legality check other than the naive one. Any alternative check that is cheaper than make_move plus check whether king is in check plus unmake_move is a guaranteed win.