voyagerOne wrote:Thanks all for your input!
So a few more things to clear the cobwebs for me...
When I hear the word "research" does that mean to research the current root node?
Typically you do a "test search" sometime called a scout search to determine if a move is as good as the one you currently consider best. It does not have to be just the root move, it is done recursively at just about any node.
if the search fails low, you don't care and you can move on because you have "proved" that it sucks.
If the search fails high, it means that the move is BETTER than you expected and you must search it again but with a larger window. You could use infiinte here since you don't really know how good it is. Generally the score returned can be viewed as a lower bound so you can start with alpha set to that score, but beta could be anything but you might want to just search it -inf +inf until it's all debugged before getting too clever.
Let say there are 12 root moves... and we get a fail high on root move #4. So we start over our search again at move #4 resting all its children to their 1st move with the adjusted window.....correct?
Yes. Only move 4 is searched again with an adjusted window.
Why is the null window set to alpha, alpha -1.... why not just alpha, alpha?
It's the interval between the 2 scores that is important. 18, 19 has NO integers between 18 and 19 so it is "zero width"
Also, beta should ALWAYS be above alpha or you have a bug. It should never be less or equal.
And finally, a zero width window ALWAYS fails, that is why it's often called a "scout" search, it's only purpose is to find out which side of the window the score is, and usually you are just trying to verify that the position is not as good.
Don't forget that a score >= beta is a failure - a common bug is to say:
if (score > beta) { do something ... }
That's a bug and should be:
if (score >= beta)
It's the same with alpha:
if (score < alpha) { is a bug }
if (score <= alpha) { fail low }
With negamax, just think of it without negamax first, then swap positions, negate and use parenthesis:
sc = -search( -beta, -alpha )
with window think like this:
sc = search( alpha-5, alpha + 5)
then rewrite it to:
sc = -search( -(alpha+5), -(alpha-5) );
which is equivalent to:
sc = -search( -alpha - 5, -alpha + 5 );
To answer your question specifically, why alpha, alpha -1?
alpha is the score that you must beat to have an impact on the tree, often it's the best move at this node. After searching the first move, you EXPECT all the others to be worse, so you want to set up a window that will fail low unless you improve on alpha. It's not good enough to find another move that is equal to alpha since it's just a waste of time so you must add 1 point.
So your window should be: alpha, alpha+1 because sc <= alpha is a fail low. To turn this into negamax you search:
sc = -search( -(alpha+1), -alpha );
which is equivalent to:
sc = -search( -alpha - 1, -alpha );
Why do one use this logic to test if it failed high score > alpha && score < beta? What's wrong with just score>alpha?
I think that was answered, but fail high is just sc >= beta. If you are not using a zero width window you want to know if the score returned is BETWEEN the 2 bounds so the test would be:
sc > alpha && sc < beta
Because
sc == alpha is a fail low and sc == beta is a fail high.
Always remember, it's the scores BETWEEN alpha and beta that matter, not alpha and beta themselves.
By the way, if alpha and beta are the same, it's logically inconsistent because if a score is returned that is equal to alpha AND beta then it has failed high AND it has failed low - which is illogical.