equal
deleted
inserted
replaced
23 }; |
23 }; |
24 |
24 |
25 typedef struct Node Node; |
25 typedef struct Node Node; |
26 |
26 |
27 Move *bestMove; |
27 Move *bestMove; |
|
28 |
28 Node *stack_end; |
29 Node *stack_end; |
29 |
30 |
30 char board[BOARD_SIZE] = { |
31 char board[BOARD_SIZE] = { |
31 EMPTY, EMPTY, EMPTY, |
32 EMPTY, EMPTY, EMPTY, |
32 EMPTY, EMPTY, EMPTY, |
33 EMPTY, EMPTY, EMPTY, |
34 }; |
35 }; |
35 |
36 |
36 int desired_depth = -1; |
37 int desired_depth = -1; |
37 |
38 |
38 int estimateFunction (); |
39 int estimateFunction (); |
|
40 |
39 int max_alpha_beta (int, int, int); |
41 int max_alpha_beta (int, int, int); |
|
42 |
40 int min_alpha_beta (int, int, int); |
43 int min_alpha_beta (int, int, int); |
|
44 |
41 void print (void); |
45 void print (void); |
42 |
46 |
43 /** |
47 /** |
44 * push: push a move onto the stack |
48 * push: push a move onto the stack |
45 */ |
49 */ |
199 * AlphaBeta-Algorithm: the Maximizer |
203 * AlphaBeta-Algorithm: the Maximizer |
200 */ |
204 */ |
201 int max_alpha_beta (int depth, int alpha, int beta) |
205 int max_alpha_beta (int depth, int alpha, int beta) |
202 { |
206 { |
203 int moveValue; |
207 int moveValue; |
|
208 |
204 int t; |
209 int t; |
|
210 |
205 Move *move; |
211 Move *move; |
206 |
212 |
207 if (desired_depth == -1) |
213 if (desired_depth == -1) |
208 desired_depth = depth; |
214 desired_depth = depth; |
209 |
215 |
240 * AlphaBeta-Algorithm: the Minimizer |
246 * AlphaBeta-Algorithm: the Minimizer |
241 */ |
247 */ |
242 int min_alpha_beta (int depth, int alpha, int beta) |
248 int min_alpha_beta (int depth, int alpha, int beta) |
243 { |
249 { |
244 int moveValue; |
250 int moveValue; |
|
251 |
245 int t; |
252 int t; |
|
253 |
246 Move *move; |
254 Move *move; |
247 |
255 |
248 t = 0; |
256 t = 0; |
249 while ((move = simulate (t, 1)) != NULL) { |
257 while ((move = simulate (t, 1)) != NULL) { |
250 /* |
258 /* |
286 } |
294 } |
287 |
295 |
288 int main (int argc, char **argv) |
296 int main (int argc, char **argv) |
289 { |
297 { |
290 Node *actual; |
298 Node *actual; |
|
299 |
291 int i, t, value; |
300 int i, t, value; |
|
301 |
292 int depth; |
302 int depth; |
293 |
303 |
294 if (argc == 2) |
304 if (argc == 2) |
295 depth = atoi (argv[1]); |
305 depth = atoi (argv[1]); |
296 else |
306 else |