1
0
Fork 0
mirror of https://github.com/sockspls/badfish synced 2025-04-29 16:23:09 +00:00

Faster perft

Skip moves scoring and sorting: this more then
doubles the speed !

Verified is correct.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
This commit is contained in:
Marco Costalba 2010-08-06 10:47:42 +01:00
parent d6904157aa
commit 3a2cd37080

View file

@ -366,26 +366,27 @@ void init_search() {
int perft(Position& pos, Depth depth) int perft(Position& pos, Depth depth)
{ {
MoveStack mlist[256];
StateInfo st; StateInfo st;
Move move; Move m;
int sum = 0; int sum = 0;
MovePicker mp(pos, MOVE_NONE, depth, H);
// Generate all legal moves
MoveStack* last = generate_moves(pos, mlist);
// If we are at the last ply we don't need to do and undo // If we are at the last ply we don't need to do and undo
// the moves, just to count them. // the moves, just to count them.
if (depth <= OnePly) // Replace with '<' to test also qsearch if (depth <= OnePly)
{ return int(last - mlist);
while (mp.get_next_move()) sum++;
return sum;
}
// Loop through all legal moves // Loop through all legal moves
CheckInfo ci(pos); CheckInfo ci(pos);
while ((move = mp.get_next_move()) != MOVE_NONE) for (MoveStack* cur = mlist; cur != last; cur++)
{ {
pos.do_move(move, st, ci, pos.move_is_check(move, ci)); m = cur->move;
pos.do_move(m, st, ci, pos.move_is_check(m, ci));
sum += perft(pos, depth - OnePly); sum += perft(pos, depth - OnePly);
pos.undo_move(move); pos.undo_move(m);
} }
return sum; return sum;
} }