Skip to content

Commit bab5a0b

Browse files
Reduce depth when recapture may not recover score.
10s+0.1 Score of tucanoNEW vs tucanoOLD: 855 - 770 - 1714 [0.513] 3339 Elo difference: 8.8 +/- 8.2, LOS: 98.3 %, DrawRatio: 51.3 % SPRT: llr 2.96 (100.5%), lbound -2.94, ubound 2.94 - H1 was accepted 60s+0.6 Score of tucanoNEW vs tucanoOLD: 1516 - 1437 - 3568 [0.506] 6521 Elo difference: 4.2 +/- 5.7, LOS: 92.7 %, DrawRatio: 54.7 % SPRT: llr 2.95 (100.3%), lbound -2.94, ubound 2.94 - H1 was accepted
1 parent 4c50628 commit bab5a0b

File tree

5 files changed

+122
-3
lines changed

5 files changed

+122
-3
lines changed

src/globals.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -537,6 +537,7 @@ U64 get_additional_threads_tbhits(void);
537537
void *ponder_search(void *game);
538538
void update_pv(PV_LINE *pv_line, int ply, MOVE move);
539539
int piece_value(int piece);
540+
int get_best_capture(BOARD *board);
540541
int is_free_passer(BOARD *board, int color, MOVE move);
541542
int has_pawn_on_rank7(BOARD *board, int color);
542543
int is_pawn_to_rank78(int turn, MOVE move);

src/main.c

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020

2121
#define ENGINE "Tucano"
2222
#define AUTHOR "Alcides Schulz"
23-
#define VERSION "12.02"
23+
#define VERSION "12.03"
2424

2525
void develop_workbench(void);
2626
double bench(int depth, int print);
@@ -111,7 +111,7 @@ int main(int argc, char *argv[])
111111
#endif
112112
settings_init();
113113
search_tables_init();
114-
114+
115115
new_game(&main_game, FEN_NEW_GAME);
116116

117117
#ifndef NDEBUG
@@ -623,11 +623,13 @@ void extract_composition(char *input_pgn);
623623
void generate_replay(char *input_pgn, char *output_pgn);
624624
void tnn_generate_menu();
625625
void generate_plain_files(char *pgn_file_list);
626+
void tnn_consolidate_files();
626627

627628
void develop_workbench(void)
628629
{
629630
//tnn_generate_menu();
630-
extract_composition("d:/temp/a.pgn");
631+
//extract_composition("d:/temp/a.pgn");
632+
tnn_consolidate_files();
631633
}
632634

633635
//END

src/nnue_gen.c

Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -296,4 +296,94 @@ void tnn_generate_menu()
296296
}
297297
}
298298

299+
void tnn_consolidate_files()
300+
{
301+
/*
302+
fen rnb1k2r/p4ppp/1qp1pn2/1p1pN3/1b1P1B1P/P3P3/1PPN1PP1/R2QKB1R w KQkq - 1 9
303+
move a3b4
304+
score 1340
305+
ply 16
306+
result 1
307+
e
308+
*/
309+
#ifdef _MSC_VER
310+
char *from_file_mask_plain = "d:/temp/temp/data_d%d_n%d_%04d.plain";
311+
char *to_file_mask_plain = "d:/temp/data/data_d%d_n%d_%04d.plain";
312+
#else
313+
char *from_file_mask_plain = "./temp/data_d%d_n%d_%04d.plain";
314+
char *to_file_mask_plain = "./data/data_d%d_n%d_%04d.plain";
315+
#endif
316+
int total_positions = 100000000;
317+
char from_file_name[1000];
318+
char to_file_name[1000];
319+
FILE *to_file = NULL;
320+
321+
char fen[500];
322+
char move[100];
323+
char score[100];
324+
char ply[100];
325+
char result[100];
326+
char e[100];
327+
328+
int write_count = 0;
329+
int write_file = 0;
330+
331+
for (int i = 0; i < 100; i++) {
332+
sprintf(from_file_name, from_file_mask_plain, 10, 0, i);
333+
FILE *from_file = fopen(from_file_name, "r");
334+
if (from_file == NULL) continue;
335+
printf("reading %s...\n", from_file_name);
336+
while (TRUE) {
337+
if (!fgets(fen, 500, from_file)) {
338+
break;
339+
}
340+
if (strncmp(fen, "fen ", 4)) {
341+
printf("error reading 'fen ': %s\n", fen);
342+
break;
343+
}
344+
if (!fgets(move, 100, from_file) || strncmp(move, "move ", 5)) {
345+
printf("error reading 'move ': %s\n", move);
346+
break;
347+
}
348+
if (!fgets(score, 100, from_file) || strncmp(score, "score ", 6)) {
349+
printf("error reading 'score ': %s\n", score);
350+
break;
351+
}
352+
if (!fgets(ply, 100, from_file) || strncmp(ply, "ply ", 4)) {
353+
printf("error reading 'ply ': %s\n", ply);
354+
break;
355+
}
356+
if (!fgets(result, 100, from_file) || strncmp(result, "result ", 7)) {
357+
printf("error reading 'result ': %s\n", result);
358+
break;
359+
}
360+
if (!fgets(e, 100, from_file) || strncmp(e, "e", 1)) {
361+
printf("error reading 'e': %s\n", e);
362+
break;
363+
}
364+
if (write_count == 0 || write_count == total_positions) {
365+
if (to_file != NULL) fclose(to_file);
366+
sprintf(to_file_name, to_file_mask_plain, 10, 0, ++write_file);
367+
to_file = fopen(to_file_name, "w");
368+
if (to_file == NULL) {
369+
printf("error opening file: %s\n", to_file_name);
370+
exit(0);
371+
}
372+
printf("\twriting %s\n", to_file_name);
373+
write_count = 0;
374+
}
375+
fputs(fen, to_file);
376+
fputs(move, to_file);
377+
fputs(score, to_file);
378+
fputs(ply, to_file);
379+
fputs(result, to_file);
380+
fputs(e, to_file);
381+
write_count++;
382+
}
383+
fclose(from_file);
384+
}
385+
if (to_file != NULL) fclose(to_file);
386+
}
387+
299388
//END
389+

src/search.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -190,6 +190,12 @@ int search(GAME *game, UINT incheck, int alpha, int beta, int depth, MOVE exclud
190190
}
191191
}
192192

193+
if (move_is_capture(get_last_move_made(&game->board))) {
194+
if (!improving && depth > 3 && depth <= 10 && eval_score + MAX(200, get_best_capture(&game->board)) < alpha) {
195+
depth--;
196+
}
197+
}
198+
193199
}
194200

195201
// Reduction when position is not on transposition table. Idea from Prodeo chess engine (from Ed Schroder).

src/search_utils.c

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,26 @@ void prepare_search(GAME *game, SETTINGS *settings)
9696
}
9797
}
9898

99+
100+
int get_best_capture(BOARD *board)
101+
{
102+
int value = PIECE_VALUE[PAWN];
103+
int turn = side_on_move(board);
104+
int opponent = flip_color(turn);
105+
106+
for (int piece = QUEEN; piece > PAWN; piece--) {
107+
if (board->state[opponent].piece[piece]) {
108+
value = PIECE_VALUE[piece];
109+
break;
110+
}
111+
}
112+
if (board->state[turn].piece[PAWN] & BB_RANK7[turn]) {
113+
value += PIECE_VALUE[QUEEN] - PIECE_VALUE[PAWN];
114+
}
115+
116+
return value;
117+
}
118+
99119
//-------------------------------------------------------------------------------------------------
100120
// Return piece value
101121
//-------------------------------------------------------------------------------------------------

0 commit comments

Comments
 (0)