Author: milix
Date: 01:11:03 01/26/04
Finally I came up with a solution!
It is not perfect yet (takes a lot of time) but it is a start,
so I post it here in case someone wants to know.
I use a little different approach. In main search,
when in horizon depth and we must decide to stand pat or go to
quiescent, I first check if the last move played was a check.
If so, I call a special routine mate_search with a depth of 2
which is increased at each iteration using the Rebel's MAX_CHECKS_DEPTH
concept. This goes like this:
if (we_are_in_horizon_depth) {
if (last_move_was_check) score = mate_search(2, turn, MATE_SCORE)
if (score != EVEN) return score
score = quiescent(alpha, beta, MATE_SCORE)
}
The routine mate_search returns a mate score if the side to move
('color_to_be_mated') get mated or EVEN otherwise.
mate_score(depth, color_to_be_mated, mate_score)
{
best = INFINITY
if (position_is_draw) return EVEN
if (depth <= 0) return EVEN
if (side_to_move_in_check) {
if (side_to_move is not color_to_be_mated) return EVEN
generate_legal_moves()
if (number_of_legal_moves is 0) return mate;
else if (number_of_legal_moves is 1) depth = depth + 2
else if (number_of_legal_moves is 2) depth = depth + 1
} else {
generate_checks()
if (no_checking_moves) return EVEN
}
for each move (m) {
make_move(m)
score = mate_search(depth-1, color_to_be_mated, mate-1)
undo_move(m)
if (side_to_move is color_to_be_mated) {
if (score == EVEN) return EVEN
} else {
if (score != EVEN) return score
}
}
if (best is INFINITY) return EVEN
return best
}
Well, the mate_search routine is not perfect, the implementation is currently
impractical because it takes too much time and it is not find the shortest mate,
I will work for it later (any suggestions appreciated!). For the test position:
FEN 5n2/B3K3/2p2Np1/4k3/7P/3bN1P1/2Prn1P1/1q6 w - - 0 1
it announces MATE IN 50 at iteration 1.
Well, it is actually a mate in 30 but I think that my routine does all possible
checks just before a 3rd repitition. The other thing I noticed is that when it
finds the mate it does not return immediatelly but takes some amount of time
before it makes that mating move.
This page took 0 seconds to execute
Last modified: Thu, 15 Apr 21 08:11:13 -0700
Current Computer Chess Club Forums at Talkchess. This site by Sean Mintz.