X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=src%2Fmovepick.cpp;h=e3d29f814f041f1d01943afb50fd97faa7cd61ae;hb=dba1bc354a74bf7774c453ac779b3ce462c2b8e2;hp=a86a1702f19d1df5ee61868a78cc93052f38b8dc;hpb=cdfe43eb8ff6f8b4315442318a4259deb4614167;p=stockfish diff --git a/src/movepick.cpp b/src/movepick.cpp index a86a1702..e3d29f81 100644 --- a/src/movepick.cpp +++ b/src/movepick.cpp @@ -23,6 +23,7 @@ #include "movegen.h" #include "movepick.h" +#include "thread.h" namespace { @@ -58,13 +59,14 @@ namespace { /// move ordering is at the current node. MovePicker::MovePicker(const Position& p, Move ttm, Depth d, const History& h, - Search::Stack* ss, Value beta) : pos(p), H(h), depth(d) { + Search::Stack* s, Value beta) : pos(p), H(h), depth(d) { assert(d > DEPTH_ZERO); captureThreshold = 0; curMove = lastMove = moves; lastBadCapture = moves + MAX_MOVES - 1; + ss = s; if (p.in_check()) phase = EVASION; @@ -166,7 +168,7 @@ void MovePicker::score_captures() { cur->score = PieceValueMidgame[pos.piece_on(to_sq(m))] - type_of(pos.piece_moved(m)); - if (is_promotion(m)) + if (type_of(m) == PROMOTION) cur->score += PieceValueMidgame[promotion_type(m)]; } } @@ -216,7 +218,7 @@ void MovePicker::generate_next() { switch (++phase) { case CAPTURES_S1: case CAPTURES_S3: case CAPTURES_S4: case CAPTURES_S5: case CAPTURES_S6: - lastMove = generate(pos, moves); + lastMove = generate(pos, moves); score_captures(); return; @@ -226,7 +228,7 @@ void MovePicker::generate_next() { return; case QUIETS_1_S1: - lastQuiet = lastMove = generate(pos, moves); + lastQuiet = lastMove = generate(pos, moves); score_noncaptures(); lastMove = std::partition(curMove, lastMove, has_positive_score); sort(curMove, lastMove); @@ -246,12 +248,12 @@ void MovePicker::generate_next() { return; case EVASIONS_S2: - lastMove = generate(pos, moves); + lastMove = generate(pos, moves); score_evasions(); return; case QUIET_CHECKS_S3: - lastMove = generate(pos, moves); + lastMove = generate(pos, moves); return; case EVASION: case QSEARCH_0: case QSEARCH_1: case PROBCUT: case RECAPTURE: @@ -270,10 +272,9 @@ void MovePicker::generate_next() { /// 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. - -Move MovePicker::next_move() { +/// searched previously. +template<> +Move MovePicker::next_move() { Move move; @@ -354,3 +355,10 @@ Move MovePicker::next_move() { } } } + + +/// Version of next_move() to use at split point nodes where the move is grabbed +/// from the split point's shared MovePicker object. This function is not thread +/// safe so should be lock protected by the caller. +template<> +Move MovePicker::next_move() { return ss->sp->mp->next_move(); }