#include "bitcount.h"
#include "movegen.h"
+#include "position.h"
// Simple macro to wrap a very common while loop, no facny, no flexibility,
// hardcoded list name 'mlist' and from square 'from'.
template<MoveType Type>
MoveStack* generate(const Position& pos, MoveStack* mlist) {
- assert(pos.is_ok());
assert(!pos.in_check());
Color us = pos.side_to_move();
template<>
MoveStack* generate<MV_NON_CAPTURE_CHECK>(const Position& pos, MoveStack* mlist) {
- assert(pos.is_ok());
assert(!pos.in_check());
Bitboard b, dc;
assert(pos.piece_on(ksq) == make_piece(opposite_color(us), KING));
// Discovered non-capture checks
- b = dc = pos.discovered_check_candidates(us);
+ b = dc = pos.discovered_check_candidates();
while (b)
{
template<>
MoveStack* generate<MV_EVASION>(const Position& pos, MoveStack* mlist) {
- assert(pos.is_ok());
assert(pos.in_check());
Bitboard b, target;
template<>
MoveStack* generate<MV_LEGAL>(const Position& pos, MoveStack* mlist) {
- assert(pos.is_ok());
-
MoveStack *last, *cur = mlist;
- Bitboard pinned = pos.pinned_pieces(pos.side_to_move());
+ Bitboard pinned = pos.pinned_pieces();
last = pos.in_check() ? generate<MV_EVASION>(pos, mlist)
: generate<MV_NON_EVASION>(pos, mlist);
inline MoveStack* generate_promotions(const Position& pos, MoveStack* mlist, Bitboard pawnsOn7, Bitboard target) {
const Bitboard TFileABB = (Delta == DELTA_NE || Delta == DELTA_SE ? FileABB : FileHBB);
- const Color Them = (Delta > 0 ? BLACK : WHITE);
Bitboard b;
Square to;
// This is the only possible under promotion that can give a check
// not already included in the queen-promotion.
if ( Type == MV_CHECK
- && bit_is_set(pos.attacks_from<KNIGHT>(to), pos.king_square(Them)))
+ && bit_is_set(pos.attacks_from<KNIGHT>(to), pos.king_square(Delta > 0 ? BLACK : WHITE)))
(*mlist++).move = make_promotion_move(to - Delta, to, KNIGHT);
else (void)pos; // Silence a warning under MSVC
}