isLegal function | bench 1812688
This commit is contained in:
1 parent
1fb235fb3f
commit
a9b51e384f
5 files changed
+109
-17
No files matched your search
+7
-3
@@ -1,8 +1,9 @@
|
||||
#include "perft.h"
|
||||
#include "stopwatch.h"
|
||||
#include "movegen.h"
|
||||
#include <cassert>
|
||||
|
||||
static U64 HelperPerft(Board board, int depth) {
|
||||
static U64 HelperPerft(Board &board, int depth) {
|
||||
MOVEGEN::GenerateMoves<All>(board, true);
|
||||
|
||||
if (depth == 0) return 1ULL;
|
||||
@@ -10,15 +11,18 @@ static U64 HelperPerft(Board board, int depth) {
|
||||
U64 nodes = 0;
|
||||
|
||||
for (int i = 0; i < board.currentMoveIndex; i++) {
|
||||
if (!board.IsLegal(board.moveList[i])) continue;
|
||||
|
||||
Board copy = board;
|
||||
bool isLegal = copy.MakeMove(board.moveList[i]);
|
||||
if (!isLegal) continue;
|
||||
copy.MakeMove(board.moveList[i]);
|
||||
|
||||
nodes += HelperPerft(copy, depth - 1);
|
||||
}
|
||||
return nodes;
|
||||
}
|
||||
|
||||
void Perft(Board &board, int depth) {
|
||||
board.SetByFen(StartingFen);
|
||||
MOVEGEN::GenerateMoves<All>(board, true);
|
||||
|
||||
U64 totalNodes = 0;
|
||||
|
||||
Reference in new issue
Block a user