int Quies(int alpha, int beta)
{
val = Evaluate();
if (val >= beta)
return beta;
if (val > alpha)
alpha = val;
GenerateGoodCaptures();
while (CapturesLeft()) {
MakeNextCapture();
val = -Quies(-beta, -alpha);
UnmakeMove();
if (val >= beta)
return beta;
if (val > alpha)
alpha = val;
}
return alpha;
}
The questions are:
1- How should work the sign of the score returned by the Evaluate function in order to Quies to work properly? (Be positive or negative depending on the side to move? The same sign always for the same side?...)
2 - An engine with an alpha-beta search that calls Quies in the leaf nodes, playing white being set at 1 ply depth, after the moves 1-Nc3, d5, should be capable to avoid the at one ply best Nd5?
Thanks in advance regards
E Diaz
Two first meanings of the dutch word "leren":
1. leren [vc] (learn, larn, acquire) acquire or gain knowledge or skills.
2. leren [v] (teach, learn, instruct) impart skills or knowledge to.
int Quies(int alpha, int beta)
{
val = Evaluate();
if (val >= beta)
return beta;
if (val > alpha)
alpha = val;
GenerateGoodCaptures();
while (CapturesLeft()) {
MakeNextCapture();
val = -Quies(-beta, -alpha);
UnmakeMove();
if (val >= beta)
return beta;
if (val > alpha)
alpha = val;
}
return alpha;
}
The questions are:
1- How should work the sign of the score returned by the Evaluate function in order to Quies to work properly? (Be positive or negative depending on the side to move? The same sign always for the same side?...)
2 - An engine with an alpha-beta search that calls Quies in the leaf nodes, playing white being set at 1 ply depth, after the moves 1-Nc3, d5, should be capable to avoid the at one ply best Nd5?
Thanks in advance regards
E Diaz
Hi,
since this is negamax, you need the eval from the point of view of the side to move. Which means that you simply negate resulting evaluation if side to move is black.
mar wrote:since this is negamax, you need the eval from the point of view of the side to move. Which means that you simply negate resulting evaluation if side to move is black.
I'm having a problem with qsearch and wanted to be sure of the very basic concepts.
Two first meanings of the dutch word "leren":
1. leren [vc] (learn, larn, acquire) acquire or gain knowledge or skills.
2. leren [v] (teach, learn, instruct) impart skills or knowledge to.
pocopito wrote:
1- How should work the sign of the score returned by the Evaluate function in order to Quies to work properly? (Be positive or negative depending on the side to move? The same sign always for the same side?...)
2 - An engine with an alpha-beta search that calls Quies in the leaf nodes, playing white being set at 1 ply depth, after the moves 1-Nc3, d5, should be capable to avoid the at one ply best Nd5?
1- score should be for the side to move. for example if it's white's turn and white is up a pawn, score should be +1 (or +100 or whatever scale you use)
2 - depth 0 actually. qsearch on Nc3 d5 should return zero (assuming material score in eval only) and chose the stand pat score and understand that Nxd5 is refuted by Qxd5
pocopito wrote:Thanks both for your clear answers.
I'm having a problem with qsearch and wanted to be sure of the very basic concepts.
Question for you: what exactly do you generate in GenerateGoodCaptures() ?
Also, you need to consider a special case: if the position is check, then you cannot stay with the stand pat score (it can even be check mate). In this case you need to generate all legal moves (check evasions) and not update alpha = max(alpha,eval), and return a mated score accordingly if there are no legal moves
lucasart wrote:Also, you need to consider a special case: if the position is check, then you cannot stay with the stand pat score (it can even be check mate). In this case you need to generate all legal moves (check evasions) and not update alpha = max(alpha,eval), and return a mated score accordingly if there are no legal moves
This would only be needed when not using check extensions in main search, since only then qsearch could be called when being in check (unless you include checks in qsearch at its upper levels, in which case I would expect to have a special qsearchEvasion() function that is called instead of qsearch() whenever a checking move has been made).
lucasart wrote:Also, you need to consider a special case: if the position is check, then you cannot stay with the stand pat score (it can even be check mate). In this case you need to generate all legal moves (check evasions) and not update alpha = max(alpha,eval), and return a mated score accordingly if there are no legal moves
This would only be needed when not using check extensions in main search, since only then qsearch could be called when being in check (unless you include checks in qsearch at its upper levels, in which case I would expect to have a special qsearchEvasion() function that is called instead of qsearch() whenever a checking move has been made).
Sven
A capture can be a checking move too !?
And yes searching quiet checks in the qsearch is useful. After some testing I came to the conclusion that 1 quiet check is best (I'm sure this is all well known, Fruit does it, and probably Cray Blitz did it in the 80s already). But the improvement going from 0 to 1 is small. 2 checks or more was a regression in my testing (which is quite logical)
In terms of design, I think it's a very poor choice to have two distinct qsearch function, one only to handle positions in check. leads to a lot of code being repeated, hence risk of discrepancy (updating sth in one function not the other). I would say the same about having different functions for PV and non PV nodes and the likes.
lucasart wrote:
Question for you: what exactly do you generate in GenerateGoodCaptures() ?
Actually I'm generating all the captures. Yes, I know it's not a good idea, but currently the problem is in some part of my code. That's why I was asking these so simple questions, to get sure I'm not wrong in some very basic concept.
Two first meanings of the dutch word "leren":
1. leren [vc] (learn, larn, acquire) acquire or gain knowledge or skills.
2. leren [v] (teach, learn, instruct) impart skills or knowledge to.