/*
Stockfish, a UCI chess playing engine derived from Glaurung 2.1
Copyright (C) 2004-2008 Tord Romstad (Glaurung author)
/*
Stockfish, a UCI chess playing engine derived from Glaurung 2.1
Copyright (C) 2004-2008 Tord Romstad (Glaurung author)
Stockfish is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
Stockfish is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
/// move ordering is at the current node.
MovePicker::MovePicker(const Position& p, Move ttm, Depth d, const History& h,
/// move ordering is at the current node.
MovePicker::MovePicker(const Position& p, Move ttm, Depth d, const History& h,
- SearchStack* ss, Value beta) : pos(p), H(h), depth(d) {
+ Search::Stack* ss, Value beta) : pos(p), H(h), depth(d) {
if (ss && ss->eval < beta - PawnValueMidgame && d < 3 * ONE_PLY)
captureThreshold = -PawnValueMidgame;
if (ss && ss->eval < beta - PawnValueMidgame && d < 3 * ONE_PLY)
captureThreshold = -PawnValueMidgame;
// Skip TT move if is not a capture or a promotion, this avoids
// qsearch tree explosion due to a possible perpetual check or
// similar rare cases when TT table is full.
// Skip TT move if is not a capture or a promotion, this avoids
// qsearch tree explosion due to a possible perpetual check or
// similar rare cases when TT table is full.
/// MovePicker::score_captures(), MovePicker::score_noncaptures() and
/// MovePicker::score_evasions() assign a numerical move ordering score
/// to each move in a move list. The moves with highest scores will be
/// MovePicker::score_captures(), MovePicker::score_noncaptures() and
/// MovePicker::score_evasions() assign a numerical move ordering score
/// to each move in a move list. The moves with highest scores will be
void MovePicker::score_captures() {
// Winning and equal captures in the main search are ordered by MVV/LVA.
void MovePicker::score_captures() {
// Winning and equal captures in the main search are ordered by MVV/LVA.
- cur->score = piece_value_midgame(pos.piece_on(move_to(m)))
- - piece_type(pos.piece_on(move_from(m)));
+ cur->score = PieceValueMidgame[pos.piece_on(move_to(m))]
+ - type_of(pos.piece_on(move_from(m)));
m = cur->move;
if ((seeScore = pos.see_sign(m)) < 0)
cur->score = seeScore - History::MaxValue; // Be sure we are at the bottom
m = cur->move;
if ((seeScore = pos.see_sign(m)) < 0)
cur->score = seeScore - History::MaxValue; // Be sure we are at the bottom
- else if (pos.move_is_capture(m))
- cur->score = piece_value_midgame(pos.piece_on(move_to(m)))
- - piece_type(pos.piece_on(move_from(m))) + History::MaxValue;
+ else if (pos.is_capture(m))
+ cur->score = PieceValueMidgame[pos.piece_on(move_to(m))]
+ - type_of(pos.piece_on(move_from(m))) + History::MaxValue;
-/// MovePicker::get_next_move() is the most important method of the MovePicker
-/// class. It returns a new pseudo legal move every time it is called, until there
+/// MovePicker::next_move() is the most important method of the MovePicker class.
+/// It returns a new pseudo legal move every time it is called, until there
/// are no more moves left. It picks the move with the biggest score from a list
/// of generated moves taking care not to return the tt move if has already been
/// searched previously. Note that this function is not thread safe so should be
/// lock protected by caller when accessed through a shared MovePicker object.
/// are no more moves left. It picks the move with the biggest score from a list
/// of generated moves taking care not to return the tt move if has already been
/// searched previously. Note that this function is not thread safe so should be
/// lock protected by caller when accessed through a shared MovePicker object.
- // Losing capture, move it to the tail of the array, note
- // that move has now been already checked for pseudo legality.
+ // Losing capture, move it to the tail of the array