Rev 33 | Rev 154 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
| Rev 33 | Rev 108 | ||
|---|---|---|---|
| Line 25... | Line 25... | ||
| 25 | * comment using (move) or {move}. Crafty will search that move in addition * |
25 | * comment using (move) or {move}. Crafty will search that move in addition * |
| 26 | * to the move actually played and the move it thinks is best. * |
26 | * to the move actually played and the move it thinks is best. * |
| 27 | * * |
27 | * * |
| 28 | * The format of the command is as follows: * |
28 | * The format of the command is as follows: * |
| 29 | * * |
29 | * * |
| 30 | * annotate filename b|w|bw|name moves margin time [n] |
30 | * annotate filename b|w|bw|name moves margin time [n] * |
| 31 | * * |
31 | * * |
| 32 | * Filename is the input file where Crafty will obtain the moves to * |
32 | * Filename is the input file where Crafty will obtain the moves to * |
| 33 | * annotate, and output will be written to file "filename.can". * |
33 | * annotate, and output will be written to file "filename.can". * |
| 34 | * * |
34 | * * |
| 35 | * annotateh filename b|w|bw|name moves margin time [n] |
35 | * annotateh filename b|w|bw|name moves margin time [n] * |
| 36 | * * |
36 | * * |
| 37 | * Can be used to produce an HTML-compatible file that includes bitmapped * |
37 | * Can be used to produce an HTML-compatible file that includes bitmapped * |
| 38 | * diagrams of the positions where Crafty provides analysis. This file can * |
38 | * diagrams of the positions where Crafty provides analysis. This file can * |
| 39 | * be opened by a browser to provide much easier 'reading'. * |
39 | * be opened by a browser to provide much easier 'reading'. * |
| 40 | * * |
40 | * * |
| 41 | * annotatet filename b|w|bw|name moves margin time [n] |
41 | * annotatet filename b|w|bw|name moves margin time [n] * |
| 42 | * * |
42 | * * |
| 43 | * Can be used to produce a LaTeX-compatible file that includes LaTeX chess * |
43 | * Can be used to produce a LaTeX-compatible file that includes LaTeX chess * |
| 44 | * fonts. This file can be read/printed by any program that can handle * |
44 | * fonts. This file can be read/printed by any program that can handle * |
| 45 | * LaTeX input. * |
45 | * LaTeX input. * |
| 46 | * * |
46 | * * |
| Line 105... | Line 105... | ||
| 105 | if (!strcmp(args[0], "annotatet")) { |
105 | if (!strcmp(args[0], "annotatet")) { |
| 106 | latex = 1; |
106 | latex = 1; |
| 107 | strcpy(html_br, "\\\\"); |
107 | strcpy(html_br, "\\\\"); |
| 108 | } |
108 | } |
| 109 | strcpy(tbuffer, buffer); |
109 | strcpy(tbuffer, buffer); |
| 110 | nargs = ReadParse(tbuffer, args, " |
110 | nargs = ReadParse(tbuffer, args, " \t;"); |
| 111 | if (nargs < 6) { |
111 | if (nargs < 6) { |
| 112 | printf |
112 | printf |
| 113 | ("usage: annotate <file> <color> <moves> <margin> <time> [nmoves]\n"); |
113 | ("usage: annotate <file> <color> <moves> <margin> <time> [nmoves]\n"); |
| 114 | return; |
114 | return; |
| 115 | } |
115 | } |
| 116 | annotate_in = fopen(args[1], "r"); |
116 | annotate_in = fopen(args[1], "r"); |
| 117 | if (annotate_in == NULL) { |
117 | if (annotate_in == NULL) { |
| 118 | Print(4095, "unable to open %s for input\n", args[1]); |
118 | Print(4095, "unable to open %s for input\n", args[1]); |
| 119 | return; |
119 | return; |
| 120 | } |
120 | } |
| 121 | nargs = ReadParse(tbuffer, args, " |
121 | nargs = ReadParse(tbuffer, args, " \t;"); |
| 122 | strcpy(text, args[1]); |
122 | strcpy(text, args[1]); |
| 123 | if (html_mode == 1) |
123 | if (html_mode == 1) |
| 124 | strcpy(text + strlen(text), ".html"); |
124 | strcpy(text + strlen(text), ".html"); |
| 125 | else if (latex == 1) |
125 | else if (latex == 1) |
| 126 | strcpy(text + strlen(text), ".tex"); |
126 | strcpy(text + strlen(text), ".tex"); |
| Line 266... | Line 266... | ||
| 266 | do { |
266 | do { |
| 267 | fflush(annotate_out); |
267 | fflush(annotate_out); |
| 268 | move = ReadNextMove(tree, buffer, 0, wtm); |
268 | move = ReadNextMove(tree, buffer, 0, wtm); |
| 269 | if (move <= 0) |
269 | if (move <= 0) |
| 270 | break; |
270 | break; |
| 271 | strcpy(text, OutputMove(tree, |
271 | strcpy(text, OutputMove(tree, 0, wtm, move)); |
| 272 | if (history_file) { |
272 | if (history_file) { |
| 273 | fseek(history_file, ((move_number - 1) * 2 + 1 - wtm) * 10, SEEK_SET); |
273 | fseek(history_file, ((move_number - 1) * 2 + 1 - wtm) * 10, SEEK_SET); |
| 274 | fprintf(history_file, "%9s\n", text); |
274 | fprintf(history_file, "%9s\n", text); |
| 275 | } |
275 | } |
| 276 | if (wtm) |
276 | if (wtm) |
| Line 314... | Line 314... | ||
| 314 | search_depth = temp[0].pathd; |
314 | search_depth = temp[0].pathd; |
| 315 | } |
315 | } |
| 316 | Print(4095, "\n Searching all legal moves."); |
316 | Print(4095, "\n Searching all legal moves."); |
| 317 | Print(4095, "----------------------------------\n"); |
317 | Print(4095, "----------------------------------\n"); |
| 318 | tree->status[1] = tree->status[0]; |
318 | tree->status[1] = tree->status[0]; |
| 319 | InitializeHashTables(); |
319 | InitializeHashTables(0); |
| 320 | annotate_score[searches_done] = Iterate(wtm, annotate, 1); |
320 | annotate_score[searches_done] = Iterate(wtm, annotate, 1); |
| 321 | if (tree->pv[0].path[1] == move) { |
321 | if (tree->pv[0].path[1] == move) { |
| 322 | player_score = annotate_score[searches_done]; |
322 | player_score = annotate_score[searches_done]; |
| 323 | player_pv = tree->pv[0]; |
323 | player_pv = tree->pv[0]; |
| 324 | search_player = 0; |
324 | search_player = 0; |
| Line 352... | Line 352... | ||
| 352 | n_root_moves = 1; |
352 | n_root_moves = 1; |
| 353 | search_time_limit = 3 * annotate_search_time_limit; |
353 | search_time_limit = 3 * annotate_search_time_limit; |
| 354 | search_depth = temp[0].pathd; |
354 | search_depth = temp[0].pathd; |
| 355 | if (search_depth == temp_search_depth) |
355 | if (search_depth == temp_search_depth) |
| 356 | search_time_limit = annotate_search_time_limit; |
356 | search_time_limit = annotate_search_time_limit; |
| 357 | InitializeHashTables(); |
357 | InitializeHashTables(0); |
| 358 | player_score = Iterate(wtm, annotate, 1); |
358 | player_score = Iterate(wtm, annotate, 1); |
| 359 | player_pv = tree->pv[0]; |
359 | player_pv = tree->pv[0]; |
| 360 | search_depth = temp_search_depth; |
360 | search_depth = temp_search_depth; |
| 361 | search_time_limit = annotate_search_time_limit; |
361 | search_time_limit = annotate_search_time_limit; |
| 362 | search_move = 0; |
362 | search_move = 0; |
| Line 438... | Line 438... | ||
| 438 | * * |
438 | * * |
| 439 | ************************************************************ |
439 | ************************************************************ |
| 440 | */ |
440 | */ |
| 441 | read_status = ReadPGN(annotate_in, 1); |
441 | read_status = ReadPGN(annotate_in, 1); |
| 442 | while (read_status == 2) { |
442 | while (read_status == 2) { |
| 443 | suggested = InputMove(tree |
443 | suggested = InputMove(tree, 0, wtm, 1, 0, buffer); |
| 444 | if (suggested > 0) { |
444 | if (suggested > 0) { |
| 445 | thinking = 1; |
445 | thinking = 1; |
| 446 | Print(4095, "\n Searching only the move suggested."); |
446 | Print(4095, "\n Searching only the move suggested."); |
| 447 | Print(4095, "--------------------\n"); |
447 | Print(4095, "--------------------\n"); |
| 448 | tree->status[1] = tree->status[0]; |
448 | tree->status[1] = tree->status[0]; |
| 449 | search_move = suggested; |
449 | search_move = suggested; |
| 450 | search_time_limit = 3 * annotate_search_time_limit; |
450 | search_time_limit = 3 * annotate_search_time_limit; |
| 451 | search_depth = temp[0].pathd; |
451 | search_depth = temp[0].pathd; |
| 452 | InitializeHashTables(); |
452 | InitializeHashTables(0); |
| 453 | annotate_score[0] = Iterate(wtm, annotate, 0); |
453 | annotate_score[0] = Iterate(wtm, annotate, 0); |
| 454 | search_depth = temp_search_depth; |
454 | search_depth = temp_search_depth; |
| 455 | search_time_limit = annotate_search_time_limit; |
455 | search_time_limit = annotate_search_time_limit; |
| 456 | search_move = 0; |
456 | search_move = 0; |
| 457 | thinking = 0; |
457 | thinking = 0; |
| Line 464... | Line 464... | ||
| 464 | } |
464 | } |
| 465 | fprintf(annotate_out, " ({suggested %d:%s}", |
465 | fprintf(annotate_out, " ({suggested %d:%s}", |
| 466 | tree->pv[0].pathd, DisplayEvaluationKibitz(annotate_score[0], |
466 | tree->pv[0].pathd, DisplayEvaluationKibitz(annotate_score[0], |
| 467 | wtm)); |
467 | wtm)); |
| 468 | for (i = 1; i <= path_len; i++) { |
468 | for (i = 1; i <= path_len; i++) { |
| 469 | fprintf(annotate_out, " %s", OutputMove(tree, |
469 | fprintf(annotate_out, " %s", OutputMove(tree, i, twtm, |
| 470 | tree->pv[0].path[i] |
470 | tree->pv[0].path[i])); |
| 471 | MakeMove(tree, i, tree->pv[0].path[i] |
471 | MakeMove(tree, i, twtm, tree->pv[0].path[i]); |
| 472 | twtm = Flip(twtm); |
472 | twtm = Flip(twtm); |
| 473 | } |
473 | } |
| 474 | for (i = path_len; i > 0; i--) { |
474 | for (i = path_len; i > 0; i--) { |
| 475 | twtm = Flip(twtm); |
475 | twtm = Flip(twtm); |
| 476 | UnmakeMove(tree, i, tree->pv[0].path[i] |
476 | UnmakeMove(tree, i, twtm, tree->pv[0].path[i]); |
| 477 | } |
477 | } |
| 478 | fprintf(annotate_out, " %s)%s\n", |
478 | fprintf(annotate_out, " %s)%s\n", |
| 479 | AnnotateVtoNAG(annotate_score[0], wtm, html_mode, latex), |
479 | AnnotateVtoNAG(annotate_score[0], wtm, html_mode, latex), |
| 480 | html_br); |
480 | html_br); |
| 481 | } |
481 | } |
| Line 484... | Line 484... | ||
| 484 | if (read_status != 2) |
484 | if (read_status != 2) |
| 485 | break; |
485 | break; |
| 486 | } |
486 | } |
| 487 | if ((analysis_printed) && (latex == 0)) |
487 | if ((analysis_printed) && (latex == 0)) |
| 488 | fprintf(annotate_out, "%s\n", html_br); |
488 | fprintf(annotate_out, "%s\n", html_br); |
| 489 | MakeMoveRoot(tree, |
489 | MakeMoveRoot(tree, wtm, move); |
| 490 | wtm = Flip(wtm); |
490 | wtm = Flip(wtm); |
| 491 | if (wtm) |
491 | if (wtm) |
| 492 | move_number++; |
492 | move_number++; |
| 493 | if (read_status != 0) |
493 | if (read_status != 0) |
| 494 | break; |
494 | break; |
| 495 | if (line2 < -1) |
495 | if (line2 < -1) |
| 496 | break; |
496 | break; |
| 497 | } while (1); |
497 | } while (1); |
| 498 | fprintf(annotate_out, " |
498 | fprintf(annotate_out, " %s %s\n\n", pgn_result, html_br); |
| 499 | if (html_mode == 1) { |
499 | if (html_mode == 1) { |
| 500 | fprintf(annotate_out, "%s\n", html_br); |
500 | fprintf(annotate_out, "%s\n", html_br); |
| 501 | AnnotateFooterHTML(annotate_out); |
501 | AnnotateFooterHTML(annotate_out); |
| 502 | } |
502 | } |
| 503 | if (latex == 1) { |
503 | if (latex == 1) { |
| Line 565... | Line 565... | ||
| 565 | fprintf(annotate_out, "<br>\n"); |
565 | fprintf(annotate_out, "<br>\n"); |
| 566 | fprintf(annotate_out, "<TABLE Border=1 CellSpacing=0 CellPadding=0>\n\n"); |
566 | fprintf(annotate_out, "<TABLE Border=1 CellSpacing=0 CellPadding=0>\n\n"); |
| 567 | for (rank = RANK8; rank >= RANK1; rank--) { |
567 | for (rank = RANK8; rank >= RANK1; rank--) { |
| 568 | fprintf(annotate_out, "<TR>\n"); |
568 | fprintf(annotate_out, "<TR>\n"); |
| 569 | for (file = FILEA; file <= FILEH; file++) { |
569 | for (file = FILEA; file <= FILEH; file++) { |
| 570 |
|
570 | strcpy(filename, "bitmaps/"); |
| 571 | if ((rank + file) % 2) |
571 | if ((rank + file) % 2) |
| 572 |
|
572 | strcat(filename, "w"); |
| 573 | else |
573 | else |
| 574 |
|
574 | strcat(filename, "b"); |
| 575 | html_piece = translate[PcOnSq((rank << 3) + file) + 6]; |
575 | html_piece = translate[PcOnSq((rank << 3) + file) + 6]; |
| 576 | switch (html_piece) { |
576 | switch (html_piece) { |
| 577 | case 'p': |
577 | case 'p': |
| 578 |
|
578 | strcat(filename, "bp"); |
| 579 |
|
579 | strcpy(alt, "*P"); |
| 580 | break; |
580 | break; |
| 581 | case 'r': |
581 | case 'r': |
| 582 |
|
582 | strcat(filename, "br"); |
| 583 |
|
583 | strcpy(alt, "*R"); |
| 584 | break; |
584 | break; |
| 585 | case 'n': |
585 | case 'n': |
| 586 |
|
586 | strcat(filename, "bn"); |
| 587 |
|
587 | strcpy(alt, "*N"); |
| 588 | break; |
588 | break; |
| 589 | case 'b': |
589 | case 'b': |
| 590 |
|
590 | strcat(filename, "bb"); |
| 591 |
|
591 | strcpy(alt, "*B"); |
| 592 | break; |
592 | break; |
| 593 | case 'q': |
593 | case 'q': |
| 594 |
|
594 | strcat(filename, "bq"); |
| 595 |
|
595 | strcpy(alt, "*Q"); |
| 596 | break; |
596 | break; |
| 597 | case 'k': |
597 | case 'k': |
| 598 |
|
598 | strcat(filename, "bk"); |
| 599 |
|
599 | strcpy(alt, "*K"); |
| 600 | break; |
600 | break; |
| 601 | case 'P': |
601 | case 'P': |
| 602 |
|
602 | strcat(filename, "wp"); |
| 603 |
|
603 | strcpy(alt, "P"); |
| 604 | break; |
604 | break; |
| 605 | case 'R': |
605 | case 'R': |
| 606 |
|
606 | strcat(filename, "wr"); |
| 607 |
|
607 | strcpy(alt, "R"); |
| 608 | break; |
608 | break; |
| 609 | case 'N': |
609 | case 'N': |
| 610 |
|
610 | strcat(filename, "wn"); |
| 611 |
|
611 | strcpy(alt, "N"); |
| 612 | break; |
612 | break; |
| 613 | case 'B': |
613 | case 'B': |
| 614 |
|
614 | strcat(filename, "wb"); |
| 615 |
|
615 | strcpy(alt, "B"); |
| 616 | break; |
616 | break; |
| 617 | case 'Q': |
617 | case 'Q': |
| 618 |
|
618 | strcat(filename, "wq"); |
| 619 |
|
619 | strcpy(alt, "Q"); |
| 620 | break; |
620 | break; |
| 621 | case 'K': |
621 | case 'K': |
| 622 |
|
622 | strcat(filename, "wk"); |
| 623 |
|
623 | strcpy(alt, "K"); |
| 624 | break; |
624 | break; |
| 625 | default: |
625 | default: |
| 626 |
|
626 | strcat(filename, "sq"); |
| 627 |
|
627 | strcpy(alt, " "); |
| 628 | break; |
628 | break; |
| 629 | } |
629 | } |
| 630 |
|
630 | strcat(filename, ".gif"); |
| 631 | fprintf(annotate_out, "<TD><IMG ALT=\"%s\" SRC=\"%s\"></TD>\n", alt, |
631 | fprintf(annotate_out, "<TD><IMG ALT=\"%s\" SRC=\"%s\"></TD>\n", alt, |
| 632 | filename); |
632 | filename); |
| 633 | } |
633 | } |
| 634 | fprintf(annotate_out, "</TR>\n\n"); |
634 | fprintf(annotate_out, "</TR>\n\n"); |
| 635 | } |
635 | } |
| Line 642... | Line 642... | ||
| 642 | } |
642 | } |
| 643 | 643 | ||
| 644 | /* |
644 | /* |
| 645 | ******************************************************************************* |
645 | ******************************************************************************* |
| 646 | * Author : Alexander Wagner * |
646 | * Author : Alexander Wagner * |
| 647 | * |
647 | * University of Michigan * |
| 648 | * Date : 03.01.04 * |
648 | * Date : 03.01.04 * |
| 649 | * * |
649 | * * |
| 650 | * Last Modified : 03.01.04 * |
650 | * Last Modified : 03.01.04 * |
| 651 | * * |
651 | * * |
| 652 | * Based upon the HTML-Code above * |
652 | * Based upon the HTML-Code above * |
| Line 698... | Line 698... | ||
| 698 | fprintf(annotate_out, "\\begin{diagram}\n\\board\n"); |
698 | fprintf(annotate_out, "\\begin{diagram}\n\\board\n"); |
| 699 | for (rank = RANK8; rank >= RANK1; rank--) { |
699 | for (rank = RANK8; rank >= RANK1; rank--) { |
| 700 | fprintf(annotate_out, " {"); |
700 | fprintf(annotate_out, " {"); |
| 701 | for (file = FILEA; file <= FILEH; file++) { |
701 | for (file = FILEA; file <= FILEH; file++) { |
| 702 | if ((rank + file) % 2) |
702 | if ((rank + file) % 2) |
| 703 |
|
703 | strcpy(filename, " "); |
| 704 | else |
704 | else |
| 705 |
|
705 | strcpy(filename, "*"); |
| 706 | html_piece = translate[PcOnSq((rank << 3) + file) + 6]; |
706 | html_piece = translate[PcOnSq((rank << 3) + file) + 6]; |
| 707 | switch (html_piece) { |
707 | switch (html_piece) { |
| 708 | case 'p': |
708 | case 'p': |
| 709 | strcpy(filename, "p"); |
709 | strcpy(filename, "p"); |
| 710 | break; |
710 | break; |