Skip to content

Commit

Permalink
Merge branch 'master' into cp-master
Browse files Browse the repository at this point in the history
  • Loading branch information
MelleKoning committed Mar 23, 2019
2 parents de0414b + 5b7e859 commit 5189d06
Showing 1 changed file with 6 additions and 8 deletions.
14 changes: 6 additions & 8 deletions src/chess/board.cc
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@

#include "chess/board.h"

#include <algorithm>
#include <cctype>
#include <cstdlib>
#include <cstring>
Expand Down Expand Up @@ -911,14 +912,11 @@ bool ChessBoard::IsLegalMove(Move move,

MoveList ChessBoard::GenerateLegalMoves() const {
const KingAttackInfo king_attack_info = GenerateKingAttackInfo();
MoveList move_list = GeneratePseudolegalMoves();
MoveList result;
result.reserve(move_list.size());

for (Move m : move_list) {
if (IsLegalMove(m, king_attack_info)) result.emplace_back(m);
}

MoveList result = GeneratePseudolegalMoves();
result.erase(
std::remove_if(result.begin(), result.end(),
[&](Move m) { return !IsLegalMove(m, king_attack_info); }),
result.end());
return result;
}

Expand Down

0 comments on commit 5189d06

Please sign in to comment.