9 #include "osl/apply_move/applyMoveWithPath.h" 
   19 using namespace osl::ntesuki;
 
   24   ntesuki_assert(result.isCheckmateSuccess() ==\ 
   25    record->getValueWithPath<A>(pass_left, path).isCheckmateSuccess());\ 
   26   if (record->getValueWithPath<A>(pass_left, path).proof() == 0)\ 
   27     ntesuki_assert(record->getValueWithPath<A>(pass_left, path).disproof() > ProofDisproof::DISPROOF_LIMIT);\ 
   28   if (record->getValueWithPath<A>(pass_left, path).disproof() == 0)\ 
   29     ntesuki_assert(record->getValueWithPath<A>(pass_left, path).proof() > ProofDisproof::PROOF_LIMIT);\ 
   39 template <
class Searcher, Player P>
 
   53                     unsigned int pass_left,
 
   56       record(record), record_orig(record_orig),
 
   63     (*searcher).template defenseForProof<PlayerTraits<P>::opponent>
 
   64       (record, record_orig, pass_left, last_move);
 
   68 template <
class Searcher, Player P>
 
   81                      unsigned int pass_left,
 
   84       record(record), record_orig(record_orig),
 
   91     (*searcher).template attackForProof<PlayerTraits<P>::opponent>
 
   92       (record, record_orig, pass_left, last_move);
 
  104     : record(r), table(t)
 
  106     size_start = table.size();
 
  111     record->addChildCount(table.size() - size_start);
 
  116   unsigned int size_start;
 
  129 NtesukiSimulationSearcher::
 
  133   if (!state.isValidMove(move, 
false)) 
return false;
 
  135   if (move.
isDrop()) 
return true;
 
  142 NtesukiSimulationSearcher::
 
  145                const unsigned int pass_left,
 
  146                const Move last_move)
 
  199   if ((pass_left > 0) && 
 
  215     attackForProof<P>(record, record_orig, pass_left - 1, last_move);
 
  220   const Move move = adjustMove<P>(best_move_orig.
getMove());
 
  224       !isSafeMove<P>(move, pass_left))
 
  232   if (0 == pass_left && !move_is_check)
 
  237   if (move_is_check != best_move_orig.
isCheck())
 
  245   NtesukiRecord *record_child = table.allocateWithMove(record, move);
 
  246   if (record_child == 0)
 
  251   const NtesukiRecord* record_child_orig = table.findWithMoveConst(record_orig,
 
  253   if (!record_child_orig)
 
  268     ApplyMoveWithPath<P>::doUndoMove(state, path, move, helper);
 
  277   if (
result.isPawnDropFoul(move))
 
  282   else if (
result.isCheckmateSuccess())
 
  303 void NtesukiSimulationSearcher::
 
  306                 const unsigned int pass_left,
 
  307                 const Move last_move)
 
  323   if (state.inCheck(O))
 
  368     if(
result.isCheckmateFail())
 
  377     defenseForProof<P>(record, record_orig, pass_left - 1, last_move);
 
  399                          NtesukiMove::INVALID(), 
false);
 
  405   bool some_moves_not_generated = 
false;
 
  406   for (NtesukiMoveList::iterator move_it = moves.begin();
 
  407        move_it != moves.end(); move_it++)
 
  413     if (isscheme != NtesukiRecord::normal_is &&
 
  414         isscheme != NtesukiRecord::delay_is &&
 
  415         move.
isCheck() && pass_left > 0) 
continue;
 
  418     const NtesukiRecord* record_child_orig = table.findWithMoveConst(record_orig, move);
 
  419     if (!record_child_orig ||
 
  422       some_moves_not_generated = 
true;
 
  426     NtesukiRecord *record_child = table.allocateWithMove(record, move);
 
  427     if (record_child == 0)
 
  439                                   NtesukiMove::INVALID(), 
false);
 
  444     int pass_left_child = pass_left;
 
  445     if (move.
isPass()) --pass_left_child;
 
  448     if (result.isUnknown())
 
  456       ApplyMoveWithPath<P>::doUndoMoveOrPass(state, path,
 
  467     if (result.isCheckmateFail())
 
  475   if (some_moves_not_generated)
 
  483                          NtesukiMove::INVALID(), 
true);
 
  493 NtesukiSimulationSearcher::
 
  496                      const unsigned int pass_left,
 
  497                      const Move last_move)
 
  499   assert(P == state.turn());
 
  546     ++proof_success_count;
 
  547     ++light_proof_success_count;
 
  560   attackForProof<P>(record, record_orig, pass_left, last_move);
 
  562   if (
result.isCheckmateSuccess())
 
  564     ++proof_success_count;
 
  572 NtesukiSimulationSearcher::
 
  575                       const unsigned int pass_left,
 
  576                       const Move last_move)
 
  578   assert(P == state.turn());
 
  584       isCheckmateSuccess())
 
  618     ++proof_success_count;
 
  619     ++light_proof_success_count;
 
  621                    isCheckmateSuccess());
 
  632   defenseForProof<P>(record, record_orig, pass_left, last_move);
 
  635   if (
result.isCheckmateSuccess())
 
  637     ++proof_success_count;