Skip to content

Commit

Permalink
Revert "pseudo_legal() and MOVE_NONE"
Browse files Browse the repository at this point in the history
This reverts commit 33d9548 ,
which crashed in DEBUG mode because of the following assert in position.h

````
Assertion failed: (is_ok(m)), function capture, file ./position.h, line 369.
````

No functional change
  • Loading branch information
snicolet committed Dec 6, 2018
1 parent 7b4f9c3 commit 5c2fbcd
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
13 changes: 8 additions & 5 deletions src/movepick.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ MovePicker::MovePicker(const Position& p, Move ttm, Depth d, const ButterflyHist
assert(d > DEPTH_ZERO);

stage = pos.checkers() ? EVASION_TT : MAIN_TT;
ttMove = pos.pseudo_legal(ttm) ? ttm : MOVE_NONE;
ttMove = ttm && pos.pseudo_legal(ttm) ? ttm : MOVE_NONE;
stage += (ttMove == MOVE_NONE);
}

Expand All @@ -79,8 +79,9 @@ MovePicker::MovePicker(const Position& p, Move ttm, Depth d, const ButterflyHist
assert(d <= DEPTH_ZERO);

stage = pos.checkers() ? EVASION_TT : QSEARCH_TT;
ttMove = pos.pseudo_legal(ttm)
&& (depth > DEPTH_QS_RECAPTURES || to_sq(ttm) == recaptureSquare) ? ttm : MOVE_NONE;
ttMove = ttm
&& pos.pseudo_legal(ttm)
&& (depth > DEPTH_QS_RECAPTURES || to_sq(ttm) == recaptureSquare) ? ttm : MOVE_NONE;
stage += (ttMove == MOVE_NONE);
}

Expand All @@ -92,7 +93,8 @@ MovePicker::MovePicker(const Position& p, Move ttm, Value th, const CapturePiece
assert(!pos.checkers());

stage = PROBCUT_TT;
ttMove = pos.pseudo_legal(ttm)
ttMove = ttm
&& pos.pseudo_legal(ttm)
&& pos.capture(ttm)
&& pos.see_ge(ttm, threshold) ? ttm : MOVE_NONE;
stage += (ttMove == MOVE_NONE);
Expand Down Expand Up @@ -192,7 +194,8 @@ Move MovePicker::next_move(bool skipQuiets) {
/* fallthrough */

case REFUTATION:
if (select<Next>([&](){ return !pos.capture(move)
if (select<Next>([&](){ return move != MOVE_NONE
&& !pos.capture(move)
&& pos.pseudo_legal(move); }))
return move;
++stage;
Expand Down
1 change: 0 additions & 1 deletion src/position.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -579,7 +579,6 @@ bool Position::legal(Move m) const {
/// Position::pseudo_legal() takes a random move and tests whether the move is
/// pseudo legal. It is used to validate moves from TT that can be corrupted
/// due to SMP concurrent access or hash position key aliasing.
/// MOVE_NONE is represented as SQ_A1 to SQ_A1 which is never pseudo_legal.

bool Position::pseudo_legal(const Move m) const {

Expand Down

0 comments on commit 5c2fbcd

Please sign in to comment.