Author: Tord Romstad
Date: 01:21:07 10/28/05
Go up one level in this thread
On October 27, 2005 at 15:52:05, Harald Lüßen wrote:
>On October 27, 2005 at 06:35:38, Tord Romstad wrote:
>
>>int search(int alpha, int beta, int depth) {
>> int value, moves_searched;
>>
>> do_nullmove();
>> value = -search(-beta, -beta + 1, depth - 4);
>> undo_nullmove();
>> if(value >= beta) return value;
>> else {
>> ThreatMove[Ply] = BestMove[Ply+1];
>> if(Reduction[Ply-1] &&
>> from_square(ThreatMove[Ply]) == to_square(CurrentMove[Ply-1]))
>
>OK, that answers the question of 'same piece'.
>
>> return alpha - 1;
>
>The caller will see this as beta + 1.
Oops, you are right. As I feared, I introduced a bug when I simplified
my search to a very short piece of pseudo-code. My search is PVS,
but in order to make the psudo code as short as possible I changed it
to plain alpha beta.
Consider the situation whan using PVS: Because the first move at any
node is never reduced, all the reduced depth searches will be done with
a zero window around alpha. In other words, the caller won't see the
return value above as beta+1, but as alpha+1.
>Hm? Will there be a cutoff instead of a research? Let's see...
>
>> }
>>
>> generate_moves();
>> moves_searched = 0;
>> while((CurrentMove[Ply] = pick_move()) && alpha < beta) {
>> do_move(CurrentMove[Ply]);
>> if(moves_searched > 3 && ok_to_reduce(move))
> {
> Reduction[ply] = true; // ?
Yes.
>> value = -search(-beta, -alpha, depth - 2);
>
> Reduction[ply] = false; // ?
Yes again. :-)
>This was the reduction.
> }
>> else value = alpha + 1;
>
>And this is just a trick to slip into the if-clause below?
Yes, it is. The if-clause (which contains the full width search)
will be executed if the program decided not to reduce the move,
or if the reduced depth search returned a score bigger than
alpha.
I am not sure I understand the rest of your questions, but I
suppose you may just be confused by the bug I introduced
when removing PVS, and by a later bug where I call undo_move
too early. Here's another attempt, which is hopefully correct:
int search(int alpha, int beta, int depth) {
int value, moves_searched;
do_nullmove();
value = -search(-beta, -beta + 1, depth - 4);
undo_nullmove();
if(value >= beta) return value;
else {
ThreatMove[Ply] = BestMove[Ply+1];
if(Reduction[Ply-1] &&
from_square(ThreatMove[Ply]) == to_square(CurrentMove[Ply-1]))
return alpha - 1;
}
generate_moves();
moves_searched = 0;
while((CurrentMove[Ply] = pick_move()) && alpha < beta) {
do_move(CurrentMove[Ply]);
if(moves_searched == 0) { // Search first move with full window:
value = -search(-beta, -alpha, depth - 1);
else {
if(moves_searched > 3 && ok_to_reduce(move)) // Reduce
value = -search(-alpha-1, -alpha, depth - 2);
else value = alpha + 1; // HACK
if(value > alpha) {
value = -search(-alpha-1, -alpha, depth - 1);
if(value > alpha && value < beta
value = -search(-beta, -alpha, depth - 1);
}
undo_move(CurrentMove[Ply]);
moves_searched++;
// OK, we've finished searching this move. Change alpha if necessary:
if(value > alpha) alpha = value;
}
return alpha;
}
Tord
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.