Depth depth, int ply, int threadID);
void sp_search(SplitPoint *sp, int threadID);
void sp_search_pv(SplitPoint *sp, int threadID);
Depth depth, int ply, int threadID);
void sp_search(SplitPoint *sp, int threadID);
void sp_search_pv(SplitPoint *sp, int threadID);
void init_search_stack(SearchStack ss[]);
void init_node(const Position &pos, SearchStack ss[], int ply, int threadID);
void update_pv(SearchStack ss[], int ply);
void sp_update_pv(SearchStack *pss, SearchStack ss[], int ply);
bool connected_moves(const Position &pos, Move m1, Move m2);
bool move_is_killer(Move m, const SearchStack& ss);
void init_search_stack(SearchStack ss[]);
void init_node(const Position &pos, SearchStack ss[], int ply, int threadID);
void update_pv(SearchStack ss[], int ply);
void sp_update_pv(SearchStack *pss, SearchStack ss[], int ply);
bool connected_moves(const Position &pos, Move m1, Move m2);
bool move_is_killer(Move m, const SearchStack& ss);
- Depth extension(const Position &pos, Move m, bool pvNode, bool check, bool singleReply, bool mateThreat);
+ Depth extension(const Position &pos, Move m, bool pvNode, bool check, bool singleReply, bool mateThreat, bool* extendable);
bool ok_to_do_nullmove(const Position &pos);
bool ok_to_prune(const Position &pos, Move m, Move threat, Depth d);
bool ok_to_use_TT(const TTEntry* tte, Depth depth, Value beta, int ply);
bool ok_to_do_nullmove(const Position &pos);
bool ok_to_prune(const Position &pos, Move m, Move threat, Depth d);
bool ok_to_use_TT(const TTEntry* tte, Depth depth, Value beta, int ply);
{
MaxSearchTime = myTime / 30 + myIncrement;
AbsoluteMaxSearchTime = Max(myTime / 4, myIncrement - 100);
{
MaxSearchTime = myTime / 30 + myIncrement;
AbsoluteMaxSearchTime = Max(myTime / 4, myIncrement - 100);
- ext = extension(pos, move, true, pos.move_is_check(move), false, false);
+ bool dummy;
+ ext = extension(pos, move, true, pos.move_is_check(move), false, false, &dummy);
newDepth = (Iteration - 2) * OnePly + ext + InitialDepth;
// Make the move, and search it
newDepth = (Iteration - 2) * OnePly + ext + InitialDepth;
// Make the move, and search it
else
{
value = -search(pos, ss, -alpha, newDepth, 1, true, 0);
else
{
value = -search(pos, ss, -alpha, newDepth, 1, true, 0);
- Depth ext = extension(pos, move, true, moveIsCheck, singleReply, mateThreat);
+ bool extendable;
+ Depth ext = extension(pos, move, true, moveIsCheck, singleReply, mateThreat, &extendable);
// Try to reduce non-pv search depth by one ply if move seems not problematic,
// if the move fails high will be re-searched at full depth.
if ( depth >= 2*OnePly
// Try to reduce non-pv search depth by one ply if move seems not problematic,
// if the move fails high will be re-searched at full depth.
if ( depth >= 2*OnePly
if (ok_to_history(pos, m)) // Only non capture moves are considered
{
update_history(pos, m, depth, movesSearched, moveCount);
if (ok_to_history(pos, m)) // Only non capture moves are considered
{
update_history(pos, m, depth, movesSearched, moveCount);
}
TT.store(pos, value_to_tt(bestValue, ply), depth, m, VALUE_TYPE_LOWER);
}
}
TT.store(pos, value_to_tt(bestValue, ply), depth, m, VALUE_TYPE_LOWER);
}
- Depth ext = extension(pos, move, false, moveIsCheck, singleReply, mateThreat);
+ bool extendable;
+ Depth ext = extension(pos, move, false, moveIsCheck, singleReply, mateThreat, &extendable);
// Try to reduce non-pv search depth by one ply if move seems not problematic,
// if the move fails high will be re-searched at full depth.
if ( depth >= 2*OnePly
// Try to reduce non-pv search depth by one ply if move seems not problematic,
// if the move fails high will be re-searched at full depth.
if ( depth >= 2*OnePly
- Depth ext = extension(pos, move, false, moveIsCheck, false, false);
+ bool extendable;
+ Depth ext = extension(pos, move, false, moveIsCheck, false, false, &extendable);
// Try to reduce non-pv search depth by one ply if move seems not problematic,
// if the move fails high will be re-searched at full depth.
// Try to reduce non-pv search depth by one ply if move seems not problematic,
// if the move fails high will be re-searched at full depth.
- Depth ext = extension(pos, move, true, moveIsCheck, false, false);
+ bool extendable;
+ Depth ext = extension(pos, move, true, moveIsCheck, false, false, &extendable);
// Try to reduce non-pv search depth by one ply if move seems not problematic,
// if the move fails high will be re-searched at full depth.
// Try to reduce non-pv search depth by one ply if move seems not problematic,
// if the move fails high will be re-searched at full depth.
ss[ply].pv[ply] = ss[ply].pv[ply+1] = ss[ply].currentMove = MOVE_NONE;
ss[ply+2].mateKiller = MOVE_NONE;
ss[ply].threatMove = MOVE_NONE;
ss[ply].pv[ply] = ss[ply].pv[ply+1] = ss[ply].currentMove = MOVE_NONE;
ss[ply+2].mateKiller = MOVE_NONE;
ss[ply].threatMove = MOVE_NONE;
// killer moves of that ply.
bool move_is_killer(Move m, const SearchStack& ss) {
// killer moves of that ply.
bool move_is_killer(Move m, const SearchStack& ss) {
const Move* k = ss.killers;
for (int i = 0; i < KILLER_MAX; i++, k++)
if (*k == m)
const Move* k = ss.killers;
for (int i = 0; i < KILLER_MAX; i++, k++)
if (*k == m)
// particular) are searched with bigger depth than ordinary moves.
Depth extension(const Position &pos, Move m, bool pvNode,
// particular) are searched with bigger depth than ordinary moves.
Depth extension(const Position &pos, Move m, bool pvNode,
- bool check, bool singleReply, bool mateThreat) {
+ bool check, bool singleReply, bool mateThreat, bool* extendable) {
if ( pos.midgame_value_of_piece_on(move_to(m)) >= RookValueMidgame
&& ( pos.non_pawn_material(WHITE) + pos.non_pawn_material(BLACK)
- pos.midgame_value_of_piece_on(move_to(m)) == Value(0))
&& !move_promotion(m))
if ( pos.midgame_value_of_piece_on(move_to(m)) >= RookValueMidgame
&& ( pos.non_pawn_material(WHITE) + pos.non_pawn_material(BLACK)
- pos.midgame_value_of_piece_on(move_to(m)) == Value(0))
&& !move_promotion(m))