equal
deleted
inserted
replaced
72 } |
72 } |
73 |
73 |
74 board[stack_end->data->target] = EMPTY; |
74 board[stack_end->data->target] = EMPTY; |
75 |
75 |
76 actual = stack_end->prev; |
76 actual = stack_end->prev; |
77 free (stack_end->data); |
|
78 free (stack_end); |
77 free (stack_end); |
79 |
78 |
80 stack_end = actual; |
79 stack_end = actual; |
81 } |
80 } |
82 |
81 |
225 |
224 |
226 print (); |
225 print (); |
227 undo (); |
226 undo (); |
228 t++; |
227 t++; |
229 |
228 |
230 if (moveValue >= beta) |
229 if (moveValue >= beta) { |
|
230 free (move); |
231 return beta; |
231 return beta; |
|
232 } |
232 |
233 |
233 if (moveValue > alpha) { |
234 if (moveValue > alpha) { |
234 alpha = moveValue; |
235 alpha = moveValue; |
235 if (depth == desired_depth) |
236 if (depth == desired_depth) { |
|
237 if (bestMove != NULL) |
|
238 free (bestMove); |
236 bestMove = move; |
239 bestMove = move; |
237 } |
240 continue; |
|
241 } |
|
242 } |
|
243 free (move); |
238 } |
244 } |
239 |
245 |
240 return alpha; |
246 return alpha; |
241 } |
247 } |
242 |
248 |
262 moveValue = move->value; |
268 moveValue = move->value; |
263 else /* best next move */ |
269 else /* best next move */ |
264 moveValue = max_alpha_beta (depth - 1, alpha, beta); |
270 moveValue = max_alpha_beta (depth - 1, alpha, beta); |
265 |
271 |
266 undo (); |
272 undo (); |
|
273 free (move); |
267 t++; |
274 t++; |
268 |
275 |
269 if (moveValue <= alpha) |
276 if (moveValue <= alpha) |
270 return alpha; |
277 return alpha; |
271 |
278 |
336 if (bestMove == NULL) { |
343 if (bestMove == NULL) { |
337 break; |
344 break; |
338 } |
345 } |
339 |
346 |
340 board[bestMove->target] = 'O'; |
347 board[bestMove->target] = 'O'; |
|
348 free (bestMove); |
341 print (); |
349 print (); |
342 |
350 |
343 if ((estimateFunction () * estimateFunction ()) == 2500) { |
351 if ((estimateFunction () * estimateFunction ()) == 2500) { |
344 free (actual); |
352 free (actual); |
345 return EXIT_SUCCESS; |
353 return EXIT_SUCCESS; |