ai: Fix #100: Update alpha when searching
When MTD(f) is disabled, played 1000 games, Win Rate: New Vs. Old 25.7% : 17.1% : 57.2% Old Vs. New 12.9% : 28.3% : 58.8% When MTD(f) is enabled, played 250 games, Win Rate: New Vs. Old 28.4% : 14.8% : 56.8% Old Vs. New 10.8% : 32.0% : 57.2%
This commit is contained in:
parent
77b65d2cde
commit
6a7173211b
|
@ -244,6 +244,8 @@ Value qsearch(Position *pos, Sanmill::Stack<Position> &ss, Depth depth, Depth or
|
||||||
Move ttMove = MOVE_NONE;
|
Move ttMove = MOVE_NONE;
|
||||||
#endif // TT_MOVE_ENABLE
|
#endif // TT_MOVE_ENABLE
|
||||||
|
|
||||||
|
// Transposition table lookup
|
||||||
|
|
||||||
#if defined (TRANSPOSITION_TABLE_ENABLE) || defined(ENDGAME_LEARNING)
|
#if defined (TRANSPOSITION_TABLE_ENABLE) || defined(ENDGAME_LEARNING)
|
||||||
const Key posKey = pos->key();
|
const Key posKey = pos->key();
|
||||||
#endif
|
#endif
|
||||||
|
@ -275,7 +277,7 @@ Value qsearch(Position *pos, Sanmill::Stack<Position> &ss, Depth depth, Depth or
|
||||||
|
|
||||||
// check transposition-table
|
// check transposition-table
|
||||||
|
|
||||||
const Value oldAlpha = alpha;
|
const Value oldAlpha = alpha; // To flag BOUND_EXACT when eval above alpha and no available moves
|
||||||
|
|
||||||
Bound type = BOUND_NONE;
|
Bound type = BOUND_NONE;
|
||||||
|
|
||||||
|
@ -331,8 +333,8 @@ Value qsearch(Position *pos, Sanmill::Stack<Position> &ss, Depth depth, Depth or
|
||||||
}
|
}
|
||||||
#endif // THREEFOLD_REPETITION
|
#endif // THREEFOLD_REPETITION
|
||||||
|
|
||||||
// recurse
|
// Initialize a MovePicker object for the current position, and prepare
|
||||||
|
// to search the moves.
|
||||||
MovePicker mp(*pos);
|
MovePicker mp(*pos);
|
||||||
Move nextMove = mp.next_move();
|
Move nextMove = mp.next_move();
|
||||||
const int moveCount = mp.move_count();
|
const int moveCount = mp.move_count();
|
||||||
|
@ -369,10 +371,13 @@ Value qsearch(Position *pos, Sanmill::Stack<Position> &ss, Depth depth, Depth or
|
||||||
#endif // !DISABLE_PREFETCH
|
#endif // !DISABLE_PREFETCH
|
||||||
#endif // TRANSPOSITION_TABLE_ENABLE
|
#endif // TRANSPOSITION_TABLE_ENABLE
|
||||||
|
|
||||||
|
// Loop through the moves until no moves remain or a beta cutoff occurs
|
||||||
for (int i = 0; i < moveCount; i++) {
|
for (int i = 0; i < moveCount; i++) {
|
||||||
ss.push(*(pos));
|
ss.push(*(pos));
|
||||||
const Color before = pos->sideToMove;
|
const Color before = pos->sideToMove;
|
||||||
Move move = mp.moves[i].move;
|
Move move = mp.moves[i].move;
|
||||||
|
|
||||||
|
// Make and search the move
|
||||||
pos->do_move(move);
|
pos->do_move(move);
|
||||||
const Color after = pos->sideToMove;
|
const Color after = pos->sideToMove;
|
||||||
|
|
||||||
|
@ -435,7 +440,12 @@ Value qsearch(Position *pos, Sanmill::Stack<Position> &ss, Depth depth, Depth or
|
||||||
bestMove = move;
|
bestMove = move;
|
||||||
}
|
}
|
||||||
|
|
||||||
break;
|
if (value < beta) // Update alpha! Always alpha < beta
|
||||||
|
alpha = value;
|
||||||
|
else {
|
||||||
|
assert(value >= beta); // Fail high
|
||||||
|
break; // Fail high
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue