2 * This program is free software; you can redistribute it and/or modify
3 * it under the terms of the GNU General Public License as published by
4 * the Free Software Foundation; either version 2 of the License, or
5 * (at your option) any later version.
7 * This program is distributed in the hope that it will be useful,
8 * but WITHOUT ANY WARRANTY; without even the implied warranty of
9 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10 * GNU General Public License for more details.
12 * You should have received a copy of the GNU General Public License
13 * along with this program; if not, write to the Free Software
14 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
22 /* TODO: better EPD knowlege */
23 enum EPD_TASKS
{ EPD_BEST_MOVE
, EPD_AVOID_MOVE
};
25 /* load EPD positions from file and solve them */
26 void *run_epd_test(void *args
)
30 struct epd_info_t
*ei
;
31 char dummy
[MAX_STRING
];
32 char target_move1
[MAX_STRING
];
33 char target_move2
[MAX_STRING
];
34 char epd_line
[MAX_STRING
];
35 char epd_type
[MAX_STRING
];
36 int epd_count
, epd_processed
, epd_solved
, epd_task
;
38 /* args - struct epd_info_t */
39 ei
= (struct epd_info_t
*)args
;
40 epd_file
= fopen(ei
->filename
, "r");
43 fprintf(stderr
, "EPD error: %s\n", strerror(errno
));
55 set_engine_value(&e
.thinking
, TRUE
);
56 set_engine_value(&e
.fixed_time
, TRUE
);
58 while (fgets(epd_line
, MAX_STRING
, epd_file
)) {
59 fprintf(stdout
, "EPD: %s", epd_line
);
61 /* seek for first test */
62 if (++epd_count
< ei
->first_test
)
65 if (!setup_board(epd_line
)) {
66 /* handle incorrect lines */
67 fprintf(stderr
, "Invalid EPD!\n");
71 int target_moves
= sscanf(epd_line
, "%s %s %s %s %s %[1-8a-hNBRQx+#]"\
72 " %[1-8a-hNBRQx+#]", dummy
, dummy
, dummy
, dummy
, epd_type
, \
73 target_move1
, target_move2
) - 5;
75 /* invalid epd position */
79 if (!strncmp(epd_type
, "bm", 2))
80 epd_task
= EPD_BEST_MOVE
;
81 else if ((target_moves
> 1) && !strncmp(epd_type
, "am", 2))
82 epd_task
= EPD_AVOID_MOVE
;
88 /* set maximum search depth and convert time from seconds */
89 set_engine_value(&e
.max_depth
, 64);
90 set_engine_value(&e
.max_time
, ei
->think_time
* 100);
92 /* clear transposition table and start search */
96 san_move(move
, dummy
);
98 /* did we found the move? */
99 if (!strncmp(dummy
, target_move1
, 6)) {
100 if (epd_task
== EPD_BEST_MOVE
)
102 } else if ((target_moves
> 1) && !strncmp(dummy
, target_move2
, 6)) {
103 if (epd_task
== EPD_BEST_MOVE
)
108 fprintf(stdout
, "\n* Tested EPD's = %d, solved = %d, percent = %.2f%%, " \
109 "total = %d.\n\n", epd_processed
, epd_solved
, \
110 ((float)epd_solved
/ epd_processed
) * 100, epd_count
);
112 if (epd_count
>= ei
->max_tests
)
116 set_engine_value(&e
.fixed_time
, FALSE
);
117 set_engine_value(&e
.thinking
, FALSE
);