16 #include <boost/foreach.hpp> 
   29   checkmate::DfpnParallel dfpn;
 
   55                          const NumEffectState& src, 
const vector<Move>& 
moves,
 
   62   for (
int i=0; i<=last_move; ++i) {
 
   65     if (! state.isValidMove(move))
 
   67     key = key.newMakeMove(move);
 
   70   if (HashKey(src) != key)
 
   72   for (
size_t i=0; i<keys.size(); ++i) 
 
   79                          const NumEffectState& src, 
const vector<Move>& ,
 
   87   NumEffectState s(src);
 
   89   shared.
checkmate = isCheckmate(s, dummy, 
false);
 
   94                     const NumEffectState& src, 
const vector<Move>& ,
 
  102   NumEffectState s(src);
 
  108                        const NumEffectState& src, 
const vector<Move>& 
moves,
 
  120   if (moves[last_move].ptype() == 
KING) 
 
  122     if (src.hasEffectAt(src.turn(), moves[last_move].from()))
 
  124     if (moves[last_move].capturePtype() != 
PTYPE_EMPTY)
 
  127       if (src.hasEffectIf(captured, moves[last_move].to(),
 
  128                               moves[last_move].from()))
 
  133   const PieceMask pin = src.pin(
alt(src.turn()));
 
  134   if (pin.test(src.pieceAt(moves[last_move].to()).number()))
 
  136   if (moves[last_move].capturePtype() != 
PTYPE_EMPTY)
 
  139     if (src.hasEffectIf(captured, moves[last_move].to(),
 
  140                             src.kingSquare(
alt(src.turn()))))
 
  148                           const NumEffectState& src, 
const vector<Move>& 
moves,
 
  156   NumEffectState s(src);
 
  166                            const NumEffectState& src, 
const vector<Move>& history,
 
  171   const Square last_to = history[last_move].to();
 
  172   if (! src.hasEffectAt(src.turn(), last_to))
 
  174   MoveVector all, 
moves;
 
  176   BOOST_FOREACH(
Move m, all)
 
  177     if (m.
to() == last_to)
 
  181   BOOST_FOREACH(
Move move, moves)
 
  184     NumEffectState s(src);
 
  190                                     checkmate_move, move);
 
  193                             checkmate_move, move);
 
  198       if (See::see(src, move) > 0)
 
  208                           const NumEffectState& src, 
const vector<Move>& history,
 
  213   const Square last_to = history[last_move].to();
 
  214   if (! src.inCheck() || src.hasEffectAt(src.turn(), last_to))
 
  221   BOOST_FOREACH (
Move move, moves) 
 
  225     if (src.hasEffectAt(
alt(src.turn()), to)
 
  226         && (src.countEffect(src.turn(), to)
 
  227             - (move.
isDrop() ? 0 : 1) == 0))
 
  234     NumEffectState s(src);
 
  240                                     checkmate_move, move);
 
  243                             checkmate_move, move);
 
  271                               const NumEffectState& src, 
const vector<Move>& ,
 
  279   const PieceMask effected_pieces = src.effectedMask(
alt(src.turn())) & src.piecesOnBoard(src.turn());
 
  283     if (src.hasPieceOnStand(src.turn(), ptype))
 
  285       NumEffectState s(src.emulateHandPiece(src.turn(), 
alt(src.turn()), ptype));
 
  286       s.setTurn(
alt(src.turn()));
 
  289       const bool threatmate
 
  292                                       hand_move, Move::PASS(
alt(s.turn())));
 
  295                               hand_move, Move::PASS(
alt(s.turn())));
 
  306     Piece p = src.pieceOf(m.takeOneBit());
 
  307     while (m.any() && !suitable(src, p))
 
  308       p = src.pieceOf(m.takeOneBit());
 
  309     if (! suitable(src, p))
 
  313     NumEffectState s(src.emulateCapture(p, 
alt(src.turn())));
 
  314     s.setTurn(
alt(src.turn()));
 
  315     if (s.inCheck() || s.inCheck(
alt(s.turn())))
 
  319     const bool threatmate
 
  322                                     board_move, Move::PASS(
alt(s.turn())));
 
  325                             board_move, Move::PASS(
alt(s.turn())));
 
  336     MoveWithComment do_search(
const NumEffectState& src, 
int seconds)
 
  353                const NumEffectState& src, 
const vector<Move>& history,
 
  366       || response.
move.
to() == history[last_move].to())
 
  369   NumEffectState s = src;
 
  373   MoveWithComment pv = do_search(s, 2);
 
  374   if (! pv.move.isNormal())
 
  376   if (See::see(s, pv.move) > 0) {
 
  377     if (pv.move.from() == history[last_move].to())
 
  379     const Piece p = s.pieceAt(pv.move.to());
 
  381         && ! s.hasEffectAt(
alt(s.turn()), pv.move.to())
 
  382         && src.effectedChanged(
alt(s.turn())).test(p.
number()))
 
  393   shared.
vision.
pv.push_back(pv.move);
 
  394   BOOST_FOREACH(
Move m, pv.moves)