Author: Koundinya Veluri
Date: 10:44:57 09/08/03
Go up one level in this thread
On September 08, 2003 at 13:02:22, Russell Reagan wrote:
>On September 08, 2003 at 03:28:16, Koundinya Veluri wrote:
>
>>I have something like this:
>>
>>int AlphaBeta (int depth, int alpha, int beta) {
>> int bestscore = -(CHECKMATE_VALUE - ply); // changed
>> if (depth == 0)
>> return Evaluate();
>> GenerateLegalMoves();
>> while (MovesLeft()) {
>> MakeMove();
>> int val = -AlphaBeta(depth - 1, -beta, -alpha); // slightly changed
>> UndoMove();
>> if (val >= beta)
>> return val;
>
>
>> if (val > bestscore) { // changed
>> bestscore = val; // changed
>> if (val > alpha) // added
>> alpha = val; // added
>> }
>
>In the if statement above, is the inner if statement necessary? It seems that if
>val is greater than bestscore, val will also be greater than alpha. Would it be
>okay to do this instead?
>
>if (val > bestscore) {
> bestscore = val;
> alpha = bestscore;
>}
>
It's not the same thing because bestscore starts at -CHECKMATE_VALUE + ply
whereas alpha can start off much higher than that. bestscore is lower than alpha
until the search of a move gives a value >= the initial alpha. So if the first
move fails low, bestscore will be increased, while alpha doesn't change.
>
>>I thought yes, but now that I think about it again, in a checkmated position,
>>fail-soft would return the correct checkmate score but fail-hard would return
>>alpha which would be -INFINITY :/... There might be something wrong in my
>>thinking here. Or, perhaps fail-hard should be tweaked to handle mate scores
>>when there are no legal moves.
>
>In the fail hard version, I usually do something like this, instead of just
>return alpha at the end of the function:
>
>if (there_are_no_legal_moves) {
> if (side_to_move_is_in_check)
> return -INFINITY + current_depth;
> return STALEMATE;
>}
>return alpha;
Ah ok, I forgot about the stalemate. I do something like that at the end to
separate stalemates from checkmates.
Regards,
Koundinya
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.