14 #include <boost/foreach.hpp> 
   18                                    const NumEffectState& state, 
Square to,
 
   20                                    MoveLogProbVector& 
out)
 
   22   const Player Turn = state.turn();
 
   23   default_prob = 
std::max(default_prob, 150);
 
   24   if (state.hasPieceOnStand<
PAWN>(Turn))
 
   26     if (! state.isPawnMaskSet(Turn, to.
x())
 
   28         && limit >= default_prob-100)
 
   31   if (state.hasPieceOnStand<
LANCE>(Turn)
 
   33       && limit >= default_prob-50)
 
   35   if (default_prob > limit)
 
   38   if (state.hasPieceOnStand<
KNIGHT>(Turn)
 
   41   if (state.hasPieceOnStand<
SILVER>(Turn))
 
   43   if (state.hasPieceOnStand<
GOLD>(Turn))
 
   45   if (state.hasPieceOnStand<
BISHOP>(Turn))
 
   47   if (state.hasPieceOnStand<
ROOK>(Turn))
 
   55   const Piece my_king = state.kingPiece(Turn);
 
   60   if (! threatmate_move.
isDrop()
 
   65     Piece piece=state.pieceAt(p);
 
   66     for (; piece.
isEmpty(); p+=step, piece=state.pieceAt(p))
 
   68     if (piece.isPiece() && piece.owner() == 
alt(Turn)
 
   69         && state.hasEffectByPiece(piece, threatmate_move.
from())) {
 
   80     mask_t attack = state.longEffectAt(target, 
alt(Turn));
 
   81     while (attack.any()) {
 
   87           (state, my_king, 
target, state.pieceOf(num).square(), 
store);
 
   90           (state, my_king, 
target, state.pieceOf(num).square(), 
store);
 
   97                   const MoveVector& all_moves, MoveLogProbVector& 
out)
 
   99   const Player Turn = state.turn();
 
  100   const int max_prob = state.king8Info(state.turn()).liberty() ? limit : 100;
 
  101   BOOST_FOREACH(
Move move, all_moves)
 
  109           && state.hasEffectByPiece(state.pieceOnBoard(move.
from()), target))
 
  113     const int me = state.countEffect(Turn, to) + (move.
isDrop() ? 1 : 0);
 
  114     const int op = state.countEffect(
alt(Turn), to);
 
  115     int prob = (move.
isDrop() ? 100 : 100); 
 
  124               && (to.
x() == 1 || to.
x() == 9)))
 
  128       if (! ((me >= 2) || (op == 0)))
 
  142          MoveLogProbVector& 
out)
 
  145   const Player Turn = state.turn();
 
  147   MoveVector all_moves;
 
  150   move_generator::GenerateAddEffectWithEffect::generate<false>
 
  151       (Turn, state, 
target, all_moves);
 
  152   generateAddEffect(limit, state, target, all_moves, out);
 
  154   if (threatmate_move.
isDrop())
 
  156     const int drop_prob = (state.hasEffectAt(
alt(Turn), target) ? 400 : 100);
 
  157     generateBreakDrop(limit, state, target, drop_prob, out);
 
  167       for (
Square to = from + offset; to != 
target; to += offset) 
 
  169         assert(to.isOnBoard());
 
  171         const int drop_prob = (state.hasEffectAt(Turn, to) ? 100 : 400);
 
  172         generateBreakDrop(limit, state, to, drop_prob, out);
 
  174         const int move_prob = (state.hasMultipleEffectAt(Turn, to) ? 100 : 400);
 
  175         if (move_prob > limit)
 
  179           (Turn, state, to, all_moves);
 
  180         BOOST_FOREACH(
Move move, all_moves)
 
  187   const Piece my_king = state.kingPiece(Turn);
 
  193     if (drop_candidate) {
 
  199         move_generator::GenerateAddEffectWithEffect::generate<false>
 
  200           (Turn, state, to, all_moves);
 
  201         generateAddEffect(limit, state, to, all_moves, out);
 
  206   const int king_prob = 100;
 
  207   if (king_prob <= limit)
 
  213     BOOST_FOREACH(
Move move, all_moves)
 
  215       if (state.hasEffectAt(
alt(Turn), move.
to()))
 
  233   findBlockLong(state, threatmate_move, all_moves);
 
  234   if (! all_moves.empty()) 
 
  237     if (state.hasPieceOnStand<
PAWN>(Turn)) cheapest = 
PAWN;
 
  238     else if (state.hasPieceOnStand<
LANCE>(Turn)) cheapest = 
LANCE;
 
  239     else if (state.hasPieceOnStand<
KNIGHT>(Turn)) cheapest = 
KNIGHT;
 
  242     BOOST_FOREACH(
Move m, all_moves) {
 
  243       const int d = state.countEffect(Turn, m.
to()) + m.
isDrop();
 
  244       const int a = state.countEffect(
alt(Turn), m.
to());
 
  248               && (cheapest != 
PAWN || ! state.isPawnMaskSet(m.
player(), m.
to().
x()))))
 
  255       const int prob = 150+added*50;
 
  260     if (added == 0 && chuai_reserve.
isNormal() && limit >= 250) {
 
  263         if (state.hasPieceOnStand<
SILVER>(Turn))
 
  265         else if (state.hasPieceOnStand<
GOLD>(Turn))
 
  267         else if (state.hasPieceOnStand<
BISHOP>(Turn))
 
  269         else if (state.hasPieceOnStand<
ROOK>(Turn))
 
  283   const Player Turn = state.turn();
 
  284   if (target.
owner() != Turn)
 
  287   const int capture_prob = 50;
 
  288   const int default_prob = 100;
 
  289   const int sacrifice_prob = 400;
 
  290   if (limit < capture_prob)
 
  296   BOOST_FOREACH(
Move move, moves)
 
  299     const bool sacrifice = state.hasEffectAt(
alt(Turn), move.
to());
 
  300     const int prob = capture ? capture_prob
 
  301       : (sacrifice ? sacrifice_prob : default_prob);