-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathperft.c
52 lines (35 loc) · 1.08 KB
/
perft.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
#include "ark.h"
int total_nodes = 0;
void perft(int depth, S_BOARD *board){
ASSERT(CheckBoard(board));
if(depth == 0){
total_nodes++;
return;
}
S_MOVELIST list[1];
GenerateAllMoves(board, list);
for(int i = 0; i < list->count; i++){
if(!MakeMove(board, list->moves[i].move)) continue;
perft(depth - 1, board);
TakeMove(board);
}
return;
}
void perftTest(int depth, S_BOARD *board){
printf("Starting Searching for depth : %d\n", depth);
S_MOVELIST list[1];
GenerateAllMoves(board, list);
int start = getMillis();
long cummulative_nodes;
for(int i = 0; i < list->count; i++){
if(!MakeMove(board, list->moves[i].move)){
continue;
}
cummulative_nodes = total_nodes;
perft(depth - 1, board);
TakeMove(board);
long old = total_nodes - cummulative_nodes;
printf("%2d) %s : %ld\n", i + 1, PrMove(list->moves[i].move), old);
}
printf("Total Moves Searched... %ld in %lldms\n", total_nodes, getMillis() - start);
}