-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSearch.c
More file actions
46 lines (32 loc) · 781 Bytes
/
Copy pathSearch.c
File metadata and controls
46 lines (32 loc) · 781 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
/* Travis Wolfe
* January 2010
*/
#include "Search.h"
#define QDEPTH 4
int scout(Board *board, int alpha, int beta, int depth) {
Move *moves;
int num_moves, i, val;
/* printf("scout depth %d\n", depth); */
if(depth == 0)
return quiescent(board, alpha, beta, QDEPTH);
/* loop over all moves */
moves = gen_moves(board, &num_moves);
for(i=0; i<num_moves; i++) {
/* apply the move */
apply_move(board, &moves[i]);
/* recurse */
val = -scout(board, -beta, -alpha, depth-1);
/* undo move */
undo_move(board, &moves[i]);
/* update alpha */
if(val > alpha)
alpha = val;
if(alpha >= beta)
return alpha;
}
/* free(moves); */
return alpha;
}
int quiescent(Board *board, int alpha, int beta, int depth) {
return eval(board);
}