1.4.4 Search:

Code: Select all

```
/* check our current score vs. alpha: */
if (score > alpha && legal_move) {
/* update the history heuristic since we have a cutoff: */
history_h[moves[i].from][moves[i].target] += depth;
/* try for an early cutoff: */
if (score >= beta) {
u_killers (moves[i], score);
store_hash (i_alpha, depth, score, l_bound, moves[i]);
return beta;
}
alpha = score;
/* update the pv: */
pv[ply][ply] = moves[i];
for (j = ply+1; j < pv_length[ply+1]; j++)
pv[ply][j] = pv[ply+1][j];
pv_length[ply] = pv_length[ply+1];
}
}
/* check for mate / stalemate: */
if (no_moves) {
if (in_check ()) {
alpha = -INF+ply;
}
else {
alpha = 0;
}
}
else {
/* check the 50 move rule if no mate situation is on the board: */
if (fifty > 100) {
return 0;
}
}
/* store our hash info: */
if (alpha > i_alpha)
store_hash (i_alpha, depth, alpha, exact, pv[ply][ply]);
else
store_hash (i_alpha, depth, alpha, u_bound, dummy);
return alpha;
}
```

Code: Select all

```
if (score >= beta) { <--- moved to top for pv < beta purposes...
if (moves[i].captured == npiece) {
/* update killer and history heuristics for non-captures */
u_killers(moves[i], score);
history_h[moves[i].from][moves[i].target] += 1 << depth;
}
store_hash(i_alpha, depth, beta, l_bound, moves[i]);
return beta;
}
if (score > best_score && legal_move) { <----- change - (long int best_score (best_score = score = -inf;)
best_score = score;
best_move = moves[i]; <----- at top of search - (move_s best_move = dummy)
/* check our current score vs. alpha: */
if (score > alpha && legal_move) {
/* try for an early cutoff: */
alpha = score;
/* update the pv: <--------- commented out for testing!!
pv[ply][ply] = moves[i];
for (j = ply + 1; j < pv_length[ply + 1]; j++)
pv[ply][j] = pv[ply + 1][j];
pv_length[ply] = pv_length[ply + 1];*/
}
}
}
/* check for mate / stalemate: */
if (no_moves) {
if (in_check()) {
alpha = -INF + ply;
} else {
alpha = 0;
}
} else {
/* check the 50 move rule if no mate situation is on the board: */
if (fifty > 100) {
return 0;
}
}
/* store our hash info: */ <--- changes here as well
if (alpha <= i_alpha)
store_hash(i_alpha, depth, best_score, u_bound, best_move);
else
store_hash(i_alpha, depth, best_score, exact, best_move);
return alpha;
}
```

http://sourceforge.net/projects/faile/

does not. Could anyone please confirm this strictly by reading the code I posted or by trying the test themselves? I thought I should bring it up in case anyone is trying to learn from this well commented and relatively simple source. Thanks!