add custom chess engine
This commit is contained in:
@@ -0,0 +1,22 @@
|
||||
#include "perft.h"
|
||||
|
||||
namespace chess {
|
||||
|
||||
uint64_t perft(Position& pos, int depth) {
|
||||
if (depth == 0) return 1;
|
||||
|
||||
MoveList list;
|
||||
pos.generate_legal(list);
|
||||
|
||||
if (depth == 1) return uint64_t(list.size());
|
||||
|
||||
uint64_t nodes = 0;
|
||||
for (Move m : list) {
|
||||
pos.do_move(m);
|
||||
nodes += perft(pos, depth - 1);
|
||||
pos.undo_move(m);
|
||||
}
|
||||
return nodes;
|
||||
}
|
||||
|
||||
} // namespace chess
|
||||
Reference in New Issue
Block a user