Compare commits
2 Commits
239498bc2a
...
f657f8498a
| Author | SHA1 | Date | |
|---|---|---|---|
| f657f8498a | |||
| 4a0c734eba |
16
src/search.c
16
src/search.c
@@ -60,7 +60,13 @@ u64 perft(pos_t *pos, int depth, int ply, bool output)
|
|||||||
nodes++;
|
nodes++;
|
||||||
} else {
|
} else {
|
||||||
move_do(pos, *move);
|
move_do(pos, *move);
|
||||||
subnodes = perft(pos, depth - 1, ply + 1, output);
|
if (depth == 2) {
|
||||||
|
movelist_t movelist2;
|
||||||
|
pos_set_checkers_pinners_blockers(pos);
|
||||||
|
subnodes = pos_legal(pos, pos_gen_pseudo(pos, &movelist2))->nmoves;
|
||||||
|
} else {
|
||||||
|
subnodes = perft(pos, depth - 1, ply + 1, output);
|
||||||
|
}
|
||||||
if (output && ply == 1) {
|
if (output && ply == 1) {
|
||||||
char movestr[8];
|
char movestr[8];
|
||||||
printf("%s: %d\n", move_str(movestr, *move, 0), subnodes);
|
printf("%s: %d\n", move_str(movestr, *move, 0), subnodes);
|
||||||
@@ -105,7 +111,13 @@ u64 perft_test(pos_t *pos, int depth, int ply, bool output)
|
|||||||
nodes++;
|
nodes++;
|
||||||
} else {
|
} else {
|
||||||
move_do2(pos, *move, &state);
|
move_do2(pos, *move, &state);
|
||||||
subnodes = perft_test(pos, depth - 1, ply + 1, output);
|
if (depth == 2) {
|
||||||
|
movelist_t movelist2;
|
||||||
|
pos_set_checkers_pinners_blockers(pos);
|
||||||
|
subnodes = pos_legal(pos, pos_gen_pseudo(pos, &movelist2))->nmoves;
|
||||||
|
} else {
|
||||||
|
subnodes = perft_test(pos, depth - 1, ply + 1, output);
|
||||||
|
}
|
||||||
if (output && ply == 1) {
|
if (output && ply == 1) {
|
||||||
char movestr[8];
|
char movestr[8];
|
||||||
printf("%s: %d\n", move_str(movestr, *move, 0), subnodes);
|
printf("%s: %d\n", move_str(movestr, *move, 0), subnodes);
|
||||||
|
|||||||
@@ -238,13 +238,13 @@ int main(int __unused ac, __unused char**av)
|
|||||||
pos_t *pos = NULL, *fenpos;
|
pos_t *pos = NULL, *fenpos;
|
||||||
pos_t *fishpos = pos_new();
|
pos_t *fishpos = pos_new();
|
||||||
movelist_t fishmoves;
|
movelist_t fishmoves;
|
||||||
//move_t move;
|
|
||||||
FILE *outfd = NULL;
|
FILE *outfd = NULL;
|
||||||
struct {
|
struct {
|
||||||
s64 count, ms;
|
s64 count, ms;
|
||||||
s64 minlps, maxlps;
|
s64 minlps, maxlps;
|
||||||
int skipped;
|
int skipped;
|
||||||
} res[2] = {
|
} res[3] = {
|
||||||
|
{ .minlps=LONG_MAX },
|
||||||
{ .minlps=LONG_MAX },
|
{ .minlps=LONG_MAX },
|
||||||
{ .minlps=LONG_MAX },
|
{ .minlps=LONG_MAX },
|
||||||
};
|
};
|
||||||
@@ -271,11 +271,9 @@ int main(int __unused ac, __unused char**av)
|
|||||||
return usage(*av);
|
return usage(*av);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//if (ac > 1)
|
|
||||||
// depth = atoi(av[1]);
|
printf("perft: depth = %d run = %x stockfish = %s\n",
|
||||||
//if (ac > 2)
|
depth, run, sf_run? "true": "false");
|
||||||
// run = atoi(av[2]) & 3;
|
|
||||||
printf("depth = %d run = %x sf = %s\n", depth, run, sf_run? "true": "false");
|
|
||||||
|
|
||||||
init_all();
|
init_all();
|
||||||
|
|
||||||
@@ -285,7 +283,7 @@ int main(int __unused ac, __unused char**av)
|
|||||||
if (sf_run)
|
if (sf_run)
|
||||||
outfd = open_stockfish();
|
outfd = open_stockfish();
|
||||||
|
|
||||||
CLOCK_DEFINE(clock, CLOCK_PROCESS);
|
CLOCK_DEFINE(clock, CLOCK_MONOTONIC);
|
||||||
while ((fen = next_fen(PERFT | MOVEDO))) {
|
while ((fen = next_fen(PERFT | MOVEDO))) {
|
||||||
test_line = cur_line();
|
test_line = cur_line();
|
||||||
if (!(fenpos = fen2pos(pos, fen))) {
|
if (!(fenpos = fen2pos(pos, fen))) {
|
||||||
@@ -293,10 +291,27 @@ int main(int __unused ac, __unused char**av)
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
pos = fenpos;
|
pos = fenpos;
|
||||||
if (sf_run)
|
if (sf_run) {
|
||||||
|
clock_start(&clock);
|
||||||
sf_count = send_stockfish_fen(outfd, fishpos, &fishmoves, fen, depth);
|
sf_count = send_stockfish_fen(outfd, fishpos, &fishmoves, fen, depth);
|
||||||
|
ms = clock_elapsed_ms(&clock);
|
||||||
// savepos = pos_dup(pos);
|
if (!ms) {
|
||||||
|
res[2].skipped++;
|
||||||
|
lps = 0;
|
||||||
|
} else {
|
||||||
|
lps = sf_count * 1000l / ms;
|
||||||
|
res[2].ms += ms;
|
||||||
|
res[2].count += sf_count;
|
||||||
|
if (lps > res[2].maxlps)
|
||||||
|
res[2].maxlps = lps;
|
||||||
|
if (lps < res[2].minlps)
|
||||||
|
res[2].minlps = lps;
|
||||||
|
}
|
||||||
|
printf("SF : line=%3d perft=%'lu %'ldms lps=%'lu \"%s\"\n",
|
||||||
|
test_line, sf_count, ms,
|
||||||
|
lps,
|
||||||
|
fen);
|
||||||
|
}
|
||||||
|
|
||||||
if (run & 1) {
|
if (run & 1) {
|
||||||
clock_start(&clock);
|
clock_start(&clock);
|
||||||
@@ -360,6 +375,15 @@ int main(int __unused ac, __unused char**av)
|
|||||||
// exit(0);
|
// exit(0);
|
||||||
}
|
}
|
||||||
pos_del(pos);
|
pos_del(pos);
|
||||||
|
if (sf_run) {
|
||||||
|
if (!res[2].ms)
|
||||||
|
res[2].ms = 1;
|
||||||
|
printf("total SF %'lums %'lums lps=%'lu min=%'lu max=%'lu (skipped %d)\n",
|
||||||
|
res[2].count, res[2].ms,
|
||||||
|
res[2].count * 1000l / res[2].ms,
|
||||||
|
res[2].minlps, res[2].maxlps,
|
||||||
|
res[2].skipped);
|
||||||
|
}
|
||||||
if (run & 1) {
|
if (run & 1) {
|
||||||
if (!res[0].ms)
|
if (!res[0].ms)
|
||||||
res[0].ms = 1;
|
res[0].ms = 1;
|
||||||
|
|||||||
Reference in New Issue
Block a user