Code: Select all
public int SearchRoot(int depth, int initVal, out MoveBase bestMove)
{
int WINDOW_MARGIN = 2000;
int factor = 1;
int lb = initVal - factor * WINDOW_MARGIN;
int ub = initVal + factor * WINDOW_MARGIN;
int value = Search(depth, lb, ub, out bestMove, false); ;
if (Expired())
throw new TimeoutException();
factor = factor * 4;
do
{
while (lb >= value)
{
lb = initVal - factor * WINDOW_MARGIN;
value = Search(depth, lb, ub, out bestMove, false);
if (Expired())
throw new TimeoutException();
factor = factor * 4;
}
while (ub <= value)
{
ub = initVal + factor * WINDOW_MARGIN;
value = Search(depth, lb, ub, out bestMove, false);
if (Expired())
throw new TimeoutException();
factor = factor * 4;
}
}
while (!(value > lb && value < ub));
return value;
}

