Rev 33 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 33 | Rev 108 | ||
---|---|---|---|
Line 11... | Line 11... | ||
11 | * input_move(silent=1) to let it silently check the move for uniqueness. * |
11 | * input_move(silent=1) to let it silently check the move for uniqueness. * |
12 | * as soon as we get a non-ambiguous move, we return that text string. * |
12 | * as soon as we get a non-ambiguous move, we return that text string. * |
13 | * * |
13 | * * |
14 | ******************************************************************************* |
14 | ******************************************************************************* |
15 | */ |
15 | */ |
16 | char *OutputMove(TREE * RESTRICT tree |
16 | char *OutputMove(TREE * RESTRICT tree, int ply, int wtm, int move) { |
17 | static char text_move[10], new_text[10]; |
17 | static char text_move[10], new_text[10]; |
18 |
|
18 | unsigned *mvp; |
19 | char *text; |
19 | char *text = text_move; |
20 | static const char piece_names[7] = { ' ', 'P', 'N', 'B', 'R', 'Q', 'K' }; |
20 | static const char piece_names[7] = { ' ', 'P', 'N', 'B', 'R', 'Q', 'K' }; |
21 | text = text_move; |
- | |
22 | /* |
21 | /* |
23 | ************************************************************ |
22 | ************************************************************ |
24 | * * |
23 | * * |
25 | * Special case for null-move which will only be used in a * |
24 | * Special case for null-move which will only be used in a * |
26 | * search trace which dumps the entire tree. * |
25 | * search trace which dumps the entire tree. * |
27 | * * |
26 | * * |
28 | ************************************************************ |
27 | ************************************************************ |
29 | */ |
28 | */ |
30 | if (move == 0) { |
29 | if (move == 0) { |
31 |
|
30 | strcpy(text, "null"); |
32 | return text; |
31 | return text; |
33 | } |
32 | } |
34 | do { |
33 | do { |
35 | /* |
34 | /* |
36 | ************************************************************ |
35 | ************************************************************ |
Line 40... | Line 39... | ||
40 | ************************************************************ |
39 | ************************************************************ |
41 | */ |
40 | */ |
42 | if ((Piece(move) == king) && (Abs(From(move) - To(move)) == 2)) { |
41 | if ((Piece(move) == king) && (Abs(From(move) - To(move)) == 2)) { |
43 | if (wtm) { |
42 | if (wtm) { |
44 | if (To(move) == 2) |
43 | if (To(move) == 2) |
45 |
|
44 | strcpy(text_move, "O-O-O"); |
46 | else |
45 | else |
47 |
|
46 | strcpy(text_move, "O-O"); |
48 | } else { |
47 | } else { |
49 | if (To(move) == 58) |
48 | if (To(move) == 58) |
50 |
|
49 | strcpy(text_move, "O-O-O"); |
51 | else |
50 | else |
52 |
|
51 | strcpy(text_move, "O-O"); |
53 | } |
52 | } |
54 | break; |
53 | break; |
55 | } |
54 | } |
56 | /* |
55 | /* |
57 | ************************************************************ |
56 | ************************************************************ |
Line 73... | Line 72... | ||
73 | if (Promote(move)) { |
72 | if (Promote(move)) { |
74 | *text++ = '='; |
73 | *text++ = '='; |
75 | *text++ = piece_names[Promote(move)]; |
74 | *text++ = piece_names[Promote(move)]; |
76 | } |
75 | } |
77 | *text = '\0'; |
76 | *text = '\0'; |
78 |
|
77 | strcpy(text_move, new_text); |
79 | if (output_format > 0) |
78 | if (output_format > 0) |
80 | break; |
79 | break; |
81 | /* |
80 | /* |
82 | ************************************************************ |
81 | ************************************************************ |
83 | * * |
82 | * * |
Line 88... | Line 87... | ||
88 | * * |
87 | * * |
89 | ************************************************************ |
88 | ************************************************************ |
90 | */ |
89 | */ |
91 | if (Piece(move) == pawn) { |
90 | if (Piece(move) == pawn) { |
92 | if (!Captured(move)) { |
91 | if (!Captured(move)) { |
93 |
|
92 | strcpy(text_move, new_text + 2); |
94 | if (InputMove(tree |
93 | if (InputMove(tree, ply, wtm, 1, 0, text_move)) |
95 | break; |
94 | break; |
96 | } |
95 | } |
97 | /* |
96 | /* |
98 | ************************************************************ |
97 | ************************************************************ |
99 | * * |
98 | * * |
Line 101... | Line 100... | ||
101 | * the usual pawn capture format (Pe4xd5 becomes exd5). * |
100 | * the usual pawn capture format (Pe4xd5 becomes exd5). * |
102 | * * |
101 | * * |
103 | ************************************************************ |
102 | ************************************************************ |
104 | */ |
103 | */ |
105 | text_move[0] = new_text[0]; |
104 | text_move[0] = new_text[0]; |
106 |
|
105 | strcpy(text_move + 1, new_text + 2); |
107 | if (InputMove(tree |
106 | if (InputMove(tree, ply, wtm, 1, 0, text_move)) |
108 | break; |
107 | break; |
109 | /* |
108 | /* |
110 | ************************************************************ |
109 | ************************************************************ |
111 | * * |
110 | * * |
112 | * It is a pawn move and we can't find a shorter form, so * |
111 | * It is a pawn move and we can't find a shorter form, so * |
113 | * leave it as a fully-qualified move and go with it as * |
112 | * leave it as a fully-qualified move and go with it as * |
114 | * is. (this will not normally happen). * |
113 | * is. (this will not normally happen). * |
115 | * * |
114 | * * |
116 | ************************************************************ |
115 | ************************************************************ |
117 | */ |
116 | */ |
118 |
|
117 | strcpy(text_move, new_text); |
119 | break; |
118 | break; |
120 | } |
119 | } |
121 | /* |
120 | /* |
122 | ************************************************************ |
121 | ************************************************************ |
123 | * * |
122 | * * |
Line 127... | Line 126... | ||
127 | * * |
126 | * * |
128 | ************************************************************ |
127 | ************************************************************ |
129 | */ |
128 | */ |
130 | if (!Captured(move)) { |
129 | if (!Captured(move)) { |
131 | text_move[0] = new_text[0]; |
130 | text_move[0] = new_text[0]; |
132 |
|
131 | strcpy(text_move + 1, new_text + 3); |
133 | if (InputMove(tree |
132 | if (InputMove(tree, ply, wtm, 1, 0, text_move)) |
134 | break; |
133 | break; |
135 | /* |
134 | /* |
136 | ************************************************************ |
135 | ************************************************************ |
137 | * * |
136 | * * |
138 | * If that is ambiguous, we will try two alternatives: * |
137 | * If that is ambiguous, we will try two alternatives: * |
Line 141... | Line 140... | ||
141 | * * |
140 | * * |
142 | ************************************************************ |
141 | ************************************************************ |
143 | */ |
142 | */ |
144 | text_move[0] = new_text[0]; |
143 | text_move[0] = new_text[0]; |
145 | text_move[1] = new_text[1]; |
144 | text_move[1] = new_text[1]; |
146 |
|
145 | strcpy(text_move + 2, new_text + 3); |
147 | if (InputMove(tree |
146 | if (InputMove(tree, ply, wtm, 1, 0, text_move)) |
148 | break; |
147 | break; |
149 | text_move[0] = new_text[0]; |
148 | text_move[0] = new_text[0]; |
150 |
|
149 | strcpy(text_move + 1, new_text + 2); |
151 | if (InputMove(tree |
150 | if (InputMove(tree, ply, wtm, 1, 0, text_move)) |
152 | break; |
151 | break; |
153 | /* |
152 | /* |
154 | ************************************************************ |
153 | ************************************************************ |
155 | * * |
154 | * * |
156 | * Nothing worked, so we go with the fully-qualified move. * |
155 | * Nothing worked, so we go with the fully-qualified move. * |
157 | * * |
156 | * * |
158 | ************************************************************ |
157 | ************************************************************ |
159 | */ |
158 | */ |
160 |
|
159 | strcpy(text_move, new_text); |
161 | break; |
160 | break; |
162 | } else { |
161 | } else { |
163 | /* |
162 | /* |
164 | ************************************************************ |
163 | ************************************************************ |
165 | * * |
164 | * * |
Line 167... | Line 166... | ||
167 | * capture move (Ng1xf3 becomes Nxf3) * |
166 | * capture move (Ng1xf3 becomes Nxf3) * |
168 | * * |
167 | * * |
169 | ************************************************************ |
168 | ************************************************************ |
170 | */ |
169 | */ |
171 | text_move[0] = new_text[0]; |
170 | text_move[0] = new_text[0]; |
172 |
|
171 | strcpy(text_move + 1, new_text + 3); |
173 | if (InputMove(tree |
172 | if (InputMove(tree, ply, wtm, 1, 0, text_move)) |
174 | break; |
173 | break; |
175 | /* |
174 | /* |
176 | ************************************************************ |
175 | ************************************************************ |
177 | * * |
176 | * * |
178 | * If that didn't work, we try adding in the origin file * |
177 | * If that didn't work, we try adding in the origin file * |
Line 180... | Line 179... | ||
180 | * * |
179 | * * |
181 | ************************************************************ |
180 | ************************************************************ |
182 | */ |
181 | */ |
183 | text_move[0] = new_text[0]; |
182 | text_move[0] = new_text[0]; |
184 | text_move[1] = new_text[1]; |
183 | text_move[1] = new_text[1]; |
185 |
|
184 | strcpy(text_move + 2, new_text + 3); |
186 | if (InputMove(tree |
185 | if (InputMove(tree, ply, wtm, 1, 0, text_move)) |
187 | break; |
186 | break; |
188 | text_move[0] = new_text[0]; |
187 | text_move[0] = new_text[0]; |
189 |
|
188 | strcpy(text_move + 1, new_text + 2); |
190 | if (InputMove(tree |
189 | if (InputMove(tree, ply, wtm, 1, 0, text_move)) |
191 | break; |
190 | break; |
192 | /* |
191 | /* |
193 | ************************************************************ |
192 | ************************************************************ |
194 | * * |
193 | * * |
195 | * Nothing worked, return the fully-qualified move. * |
194 | * Nothing worked, return the fully-qualified move. * |
196 | * * |
195 | * * |
197 | ************************************************************ |
196 | ************************************************************ |
198 | */ |
197 | */ |
199 |
|
198 | strcpy(text_move, new_text); |
200 | break; |
199 | break; |
201 | } |
200 | } |
202 | } while (0); |
201 | } while (0); |
203 | /* |
202 | /* |
204 | ************************************************************ |
203 | ************************************************************ |
Line 209... | Line 208... | ||
209 | ************************************************************ |
208 | ************************************************************ |
210 | */ |
209 | */ |
211 | if (output_format == 0) { |
210 | if (output_format == 0) { |
212 | text = text_move + strlen(text_move); |
211 | text = text_move + strlen(text_move); |
213 | tree->status[MAXPLY] = tree->status[ply]; |
212 | tree->status[MAXPLY] = tree->status[ply]; |
214 | MakeMove(tree, MAXPLY, |
213 | MakeMove(tree, MAXPLY, wtm, move); |
215 | if (Check(Flip(wtm))) { |
214 | if (Check(Flip(wtm))) { |
216 | mvp = |
215 | mvp = |
217 | GenerateCheckEvasions(tree, MAXPLY + 1, Flip(wtm), |
216 | GenerateCheckEvasions(tree, MAXPLY + 1, Flip(wtm), |
218 | tree->move_list + 4800); |
217 | tree->move_list + 4800); |
219 | if (mvp == (tree->move_list + 4800)) |
218 | if (mvp == (tree->move_list + 4800)) |
220 | *text++ = '#'; |
219 | *text++ = '#'; |
221 | else |
220 | else |
222 | *text++ = '+'; |
221 | *text++ = '+'; |
223 | } |
222 | } |
224 | UnmakeMove(tree, MAXPLY, |
223 | UnmakeMove(tree, MAXPLY, wtm, move); |
225 | *text = 0; |
224 | *text = 0; |
226 | } |
225 | } |
227 | return text_move; |
226 | return text_move; |
228 | } |
227 | } |