Rev 33 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
| Rev 33 | Rev 108 | ||
|---|---|---|---|
| Line 15... | Line 15... | ||
| 15 | * entered, advancing the game to the next position. * |
15 | * entered, advancing the game to the next position. * |
| 16 | * * |
16 | * * |
| 17 | ******************************************************************************* |
17 | ******************************************************************************* |
| 18 | */ |
18 | */ |
| 19 | void Analyze() { |
19 | void Analyze() { |
| 20 | int i, move, back_number, readstat = 1; |
20 | int i, v, move, back_number, readstat = 1; |
| 21 | TREE *const tree = block[0]; |
21 | TREE *const tree = block[0]; |
| 22 | 22 | ||
| 23 | /* |
23 | /* |
| 24 | ************************************************************ |
24 | ************************************************************ |
| 25 | * * |
25 | * * |
| Line 48... | Line 48... | ||
| 48 | last_pv.pathd = 0; |
48 | last_pv.pathd = 0; |
| 49 | last_pv.pathl = 0; |
49 | last_pv.pathl = 0; |
| 50 | input_status = 0; |
50 | input_status = 0; |
| 51 | pondering = 1; |
51 | pondering = 1; |
| 52 | tree->status[1] = tree->status[0]; |
52 | tree->status[1] = tree->status[0]; |
| 53 |
|
53 | Iterate(game_wtm, think, 0); |
| 54 | pondering = 0; |
54 | pondering = 0; |
| 55 | if (book_move) |
55 | if (book_move) |
| 56 | moves_out_of_book = 0; |
56 | moves_out_of_book = 0; |
| 57 | if (!xboard) { |
57 | if (!xboard) { |
| 58 | if (game_wtm) |
58 | if (game_wtm) |
| Line 71... | Line 71... | ||
| 71 | * * |
71 | * * |
| 72 | ************************************************************ |
72 | ************************************************************ |
| 73 | */ |
73 | */ |
| 74 | if (!input_status) |
74 | if (!input_status) |
| 75 | do { |
75 | do { |
| 76 | readstat = Read(1, |
76 | readstat = Read(1, buffer); |
| 77 | if (readstat < 0) |
77 | if (readstat < 0) |
| 78 | break; |
78 | break; |
| 79 | nargs = ReadParse(buffer, args, " |
79 | nargs = ReadParse(buffer, args, " \t;"); |
| 80 | Print( |
80 | Print(32, "%s\n", buffer); |
| 81 | if (strstr(args[0], "timeleft") && !xboard) { |
81 | if (strstr(args[0], "timeleft") && !xboard) { |
| 82 | if (game_wtm) |
82 | if (game_wtm) |
| 83 | printf("analyze.White(%d): ", move_number); |
83 | printf("analyze.White(%d): ", move_number); |
| 84 | else |
84 | else |
| 85 | printf("analyze.Black(%d): ", move_number); |
85 | printf("analyze.Black(%d): ", move_number); |
| 86 | fflush(stdout); |
86 | fflush(stdout); |
| 87 | } |
87 | } |
| 88 | } while (strstr(args[0], "timeleft")); |
88 | } while (strstr(args[0], "timeleft")); |
| 89 | else |
89 | else |
| 90 | nargs = ReadParse(buffer, args, " |
90 | nargs = ReadParse(buffer, args, " \t;"); |
| 91 | if (readstat < 0) |
91 | if (readstat < 0) |
| 92 | break; |
92 | break; |
| 93 | move = 0; |
93 | move = 0; |
| 94 | if (!strcmp(args[0], "exit")) |
94 | if (!strcmp(args[0], "exit")) |
| 95 | break; |
95 | break; |
| Line 115... | Line 115... | ||
| 115 | if (move_number == 0) { |
115 | if (move_number == 0) { |
| 116 | move_number = 1; |
116 | move_number = 1; |
| 117 | game_wtm = 1; |
117 | game_wtm = 1; |
| 118 | } |
118 | } |
| 119 | sprintf(buffer, "reset %d", move_number); |
119 | sprintf(buffer, "reset %d", move_number); |
| 120 |
|
120 | Option(tree); |
| 121 | display = tree->position; |
121 | display = tree->position; |
| 122 | } else if (Option(tree)) { |
122 | } else if (Option(tree)) { |
| 123 | display = tree->position; |
123 | display = tree->position; |
| 124 | } |
124 | } |
| 125 | /* |
125 | /* |
| Line 129... | Line 129... | ||
| 129 | * swap sides, and return to the top of the loop to call * |
129 | * swap sides, and return to the top of the loop to call * |
| 130 | * search from this new position. * |
130 | * search from this new position. * |
| 131 | * * |
131 | * * |
| 132 | ************************************************************ |
132 | ************************************************************ |
| 133 | */ |
133 | */ |
| 134 | else if ((move = InputMove(tree |
134 | else if ((move = InputMove(tree, 0, game_wtm, 1, 0, buffer))) { |
| 135 | char *outmove = OutputMove(tree, |
135 | char *outmove = OutputMove(tree, 0, game_wtm, move); |
| 136 | 136 | ||
| 137 | if (history_file) { |
137 | if (history_file) { |
| 138 | fseek(history_file, ((move_number - 1) * 2 + 1 - game_wtm) * 10, |
138 | fseek(history_file, ((move_number - 1) * 2 + 1 - game_wtm) * 10, |
| 139 | SEEK_SET); |
139 | SEEK_SET); |
| 140 | fprintf(history_file, "%9s\n", outmove); |
140 | fprintf(history_file, "%9s\n", outmove); |
| 141 | } |
141 | } |
| 142 | if (game_wtm) |
142 | if (game_wtm) |
| 143 | Print( |
143 | Print(32, "White(%d): ", move_number); |
| 144 | else |
144 | else |
| 145 | Print( |
145 | Print(32, "Black(%d): ", move_number); |
| 146 | Print( |
146 | Print(32, "%s\n", outmove); |
| 147 | if (speech) { |
147 | if (speech) { |
| 148 | char announce[64]; |
148 | char announce[64]; |
| 149 | 149 | ||
| 150 |
|
150 | strcpy(announce, "./speak "); |
| 151 |
|
151 | strcat(announce, outmove); |
| - | 152 | strcat(announce, " &"); |
|
| 152 | system(announce); |
153 | v = system(announce); |
| - | 154 | if (v != 0) |
|
| - | 155 | perror("Analyze() system() error: "); |
|
| 153 | } |
156 | } |
| 154 | MakeMoveRoot(tree, |
157 | MakeMoveRoot(tree, game_wtm, move); |
| 155 | display = tree->position; |
158 | display = tree->position; |
| 156 | last_mate_score = 0; |
159 | last_mate_score = 0; |
| 157 | if (log_file) |
160 | if (log_file) |
| 158 | DisplayChessBoard(log_file, tree->position); |
161 | DisplayChessBoard(log_file, tree->position); |
| 159 | } |
162 | } |