Skip to content

Commit

Permalink
Take 3: skipQuiets don't terminate with a direct check move
Browse files Browse the repository at this point in the history
bench: 3844583
  • Loading branch information
pb00068 committed Sep 11, 2019
1 parent 07acc3b commit 467d1f8
Showing 1 changed file with 3 additions and 12 deletions.
15 changes: 3 additions & 12 deletions src/movepick.cpp
Expand Up @@ -105,26 +105,17 @@ void MovePicker::score() {

static_assert(Type == CAPTURES || Type == QUIETS || Type == EVASIONS, "Wrong type");

int i=0, sum=0;
for (auto& m : *this)
if (Type == CAPTURES)
m.value = int(PieceValue[MG][pos.piece_on(to_sq(m))]) * 6
+ (*captureHistory)[pos.moved_piece(m)][to_sq(m)][type_of(pos.piece_on(to_sq(m)))];

else if (Type == QUIETS)
{
m.value = (*mainHistory)[pos.side_to_move()][from_to(m)]
+ (*continuationHistory[0])[pos.moved_piece(m)][to_sq(m)]
+ (*continuationHistory[1])[pos.moved_piece(m)][to_sq(m)]
+ (*continuationHistory[3])[pos.moved_piece(m)][to_sq(m)]
+ (*continuationHistory[5])[pos.moved_piece(m)][to_sq(m)] / 2;
sum+=m.value;
i++;
if ((pos.get_stateInfo()->checkSquares[type_of(pos.moved_piece(m))] & to_sq(m)))
m.value += abs(sum/i);
}


else // Type == EVASIONS
{
if (pos.capture(m))
Expand Down Expand Up @@ -221,11 +212,11 @@ Move MovePicker::next_move(bool skipQuiets) {
/* fallthrough */

case QUIET:
if ( !skipQuiets
&& select<Next>([&](){return *cur != refutations[0].move
if ( select<Next>([&](){return *cur != refutations[0].move
&& *cur != refutations[1].move
&& *cur != refutations[2].move;}))
return *(cur - 1);
if (!skipQuiets || ((pos.get_stateInfo()->checkSquares[type_of(pos.piece_on(from_sq(cur->move)))] & to_sq(cur->move))))
return *(cur - 1);

// Prepare the pointers to loop over the bad captures
cur = moves;
Expand Down

2 comments on commit 467d1f8

@locutus2
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@pb00068
The problem is in line 218 because the current move is at cur-1 not cur as you see if the found move is returned in the next line. So the move to which cur points can be undefined if it was the last move.

@pb00068
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep, I recognized it in the moment I saw the random benches the machines produced when starting the test.

Please sign in to comment.