#include #include #include #include "chess.h" #include "data.h" /* last modified 08/07/05 */ /* ******************************************************************************* * * * "annotate" command is used to search through the game in the "history" file* * (often set by the "read" command which reads moves in, skipping non-move * * information such as move numbers, times, etc.) * * * * the normal output of this command is a file, in PGN format, that contains * * the moves of the game, along with analysis when Crafty does not think that * * move was the best choice. the definition of "best choice" is somewhat * * vague, because if the move played is "close" to the best move available, * * Crafty will not comment on the move. "close" is defined by the * * option explained below. this basic type of annotation works by first * * using the normal tree search algorithm to find the best move. if this * * move was the move played, no output is produced. if a different move is * * considered best, then the actual move played is searched to the same depth * * and if the best move and actual move scores are within of each * * other, no comment is produced, otherwise crafty inserts the evaluation for * * the move played, followed by the eval and PV for the best continuation it * * found. you can enter suggested moves for Crafty to analyze at any point * * by simply entering a move as an analysis-type comment using (move) or * * {move}. Crafty will search that move in addition to the move actually * * played and the move it thinks is best. * * * * the format of the command is as follows: * * * * annotate filename b*w*bw*name moves margin time [n] * * * * filename is the input file where Crafty will obtain the moves to annotate, * * and output will be written to file "filename.can". * * * * annotateh filename b*w*bw*name moves margin time [n] * * * * can be used to produce an HTML-compatible file that includes bitmapped * * diagrams of the positions where Crafty provides analysis. this file can be* * opened by a browser to provide much easier 'reading'. * * * * annotatet filename b*w*bw*name moves margin time [n] * * * * can be used to produce a LaTeX-compatible file that includes LaTeX chess * * fonts. this file can be read/printed by any program that can handle LaTeX * * input. * * * * where b/w/bw indicates whether to annotate only the white side (w), the * * black side (b) or both (bw). you can also specify a name (or part of a * * name, just be sure it is unique in the name tags for clarity in who you * * mean). * * * * moves indicates the move or moves to annotate. it can be a single move, * * which indicates the starting move number to annotate, or it can be a range,* * which indicates a range of move (1-999 gets the whole game.) * * * * margin is the difference between Crafty's evaluation for the move actually * * played and for the move Crafty thinks is best, before crafty will generate * * a comment in the annotation file. 1.0 is a pawn, and will only generate * * comments if the move played is 1.000 (1 pawn) worse than the best move * * found by doing a complete search. * * * * time is time per move to search, in seconds. * * * * [n] is optional and tells Crafty to produce the PV/score for the "n" best * * moves. Crafty stops when the best move reaches the move played in the game* * or after displaying n moves, whichever comes first. if you use -n, then it* * will display n moves regardless of where the game move ranks. * * * ******************************************************************************* */ #define MIN_DECISIVE_ADV 150 #define MIN_MODERATE_ADV 70 #define MIN_SLIGHT_ADV 30 void Annotate() { FILE *annotate_in, *annotate_out; char text[128], tbuffer[512], colors[32] = { "" }, pname[128] = { ""}; int annotate_margin, annotate_score[100], player_score, best_moves, annotate_wtm; int annotate_search_time_limit, search_player; int twtm, path_len, analysis_printed = 0; int wtm, move_num, line1, line2, move, suggested, i; int searches_done, read_status; PATH temp[100], player_pv; int temp_search_depth; TREE *const tree = shared->local[0]; char html_br[5] = { "" }; int save_swindle_mode; int html_mode = 0; int latex = 0; /* ************************************************************ * * * first, quiz the user for the options needed to * * successfully annotate a game. * * * ************************************************************ */ save_swindle_mode = swindle_mode; if (!strcmp(args[0], "annotateh")) { html_mode = 1; strcpy(html_br, "
"); } if (!strcmp(args[0], "annotatet")) { latex = 1; strcpy(html_br, "\\\\"); } strcpy(tbuffer, buffer); nargs = ReadParse(tbuffer, args, " ;"); if (nargs < 6) { printf("usage: annotate