1
0
Fork 0
mirror of https://github.com/sockspls/badfish synced 2025-07-11 19:49:14 +00:00

Use a more standard perft UCI interface

Call directly 'perft 6' to search up to depth 6*OnePly
instead of the old 'perft depth 6'.

It is more in line to what other engines do. Also a bit
of cleanup while there.

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
This commit is contained in:
Marco Costalba 2009-11-13 10:27:14 +01:00
parent 7d0e0ff95e
commit a530fc2b60
2 changed files with 16 additions and 17 deletions

View file

@ -333,14 +333,14 @@ namespace {
int perft(Position& pos, Depth depth) int perft(Position& pos, Depth depth)
{ {
Move move; Move move;
MovePicker mp = MovePicker(pos, MOVE_NONE, depth, H);
int sum = 0; int sum = 0;
MovePicker mp = MovePicker(pos, MOVE_NONE, depth, H);
// 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) // Replace with '<' to test also qsearch
{ {
while ((move = mp.get_next_move()) != MOVE_NONE) sum++; while (mp.get_next_move()) sum++;
return sum; return sum;
} }
@ -348,10 +348,10 @@ int perft(Position& pos, Depth depth)
CheckInfo ci(pos); CheckInfo ci(pos);
while ((move = mp.get_next_move()) != MOVE_NONE) while ((move = mp.get_next_move()) != MOVE_NONE)
{ {
StateInfo st; StateInfo st;
pos.do_move(move, st, ci, pos.move_is_check(move, ci)); pos.do_move(move, st, ci, pos.move_is_check(move, ci));
sum += perft(pos, depth - OnePly); sum += perft(pos, depth - OnePly);
pos.undo_move(move); pos.undo_move(move);
} }
return sum; return sum;
} }

View file

@ -324,18 +324,17 @@ namespace {
void perft(UCIInputParser& uip) { void perft(UCIInputParser& uip) {
string token; string token;
int depth = 0; int depth, tm, n;
while (!uip.eof())
{
uip >> token;
if (token == "depth")
uip >> depth;
}
Position pos = RootPosition; Position pos = RootPosition;
int tm = get_system_time();
int n = perft(pos, depth * OnePly); if (uip.eof())
return;
uip >> depth;
tm = get_system_time();
n = perft(pos, depth * OnePly);
tm = get_system_time() - tm; tm = get_system_time() - tm;
std::cout << "\nNodes " << n std::cout << "\nNodes " << n
<< "\nTime (ms) " << tm << "\nTime (ms) " << tm