4 #include "osl/state/hashEffectState.h"
10 #include "osl/apply_move/applyMoveWithPath.h"
15 ntesuki_assert(result.isFinal());\
23 using namespace osl::ntesuki;
25 template <
class Searcher, Player P>
40 unsigned int pass_left,
43 record(record), record_orig(record_orig),
50 (*searcher).template defenseForDisproof<PlayerTraits<P>::opponent>
51 (record, record_orig, pass_left, last_move);
55 template <
class Searcher, Player P>
68 unsigned int pass_left,
71 record(record), record_orig(record_orig),
79 (*searcher).template attackForDisproof<PlayerTraits<P>::opponent>
80 (record, record_orig, pass_left, last_move);
91 NtesukiSimulationSearcher::
94 const unsigned int pass_left,
132 attackForDisproof<P>(record, record_orig, pass_left - 1, last_move);
135 if (!
result.isCheckmateFail())
149 bool has_loop =
false;
150 bool disproof_failed =
false;
151 for (NtesukiMoveList::iterator move_it = moves.begin();
152 move_it != moves.end(); move_it++)
156 if (move.
isPass())
continue;
158 if (!move.
isCheck() && 0 == pass_left)
continue;
163 NtesukiRecord *record_child = table.allocateWithMove(record, move);
164 if (record_child == 0)
180 if(result.isUnknown())
182 const NtesukiRecord* record_child_orig = table.findWithMoveConst(record_orig, move);
183 if (!record_child_orig ||
199 ApplyMoveWithPath<P>::doUndoMove(state, path, move.
getMove(), helper);
208 if (result.isCheckmateSuccess())
210 disproof_failed =
true;
235 NtesukiMove::INVALID(),
false);
243 NtesukiMove::INVALID(),
true);
251 NtesukiSimulationSearcher::
254 const unsigned int pass_left,
255 const Move last_move)
290 if (best_move.isInvalid())
296 const NtesukiRecord *record_child_orig = table.findWithMoveConst(record_orig, best_move);
297 if (!record_child_orig ||
306 if (!best_move.isPass() &&
307 !state.template isAlmostValidMove<false>(best_move.getMove()))
313 NtesukiRecord *record_child = table.allocateWithMove(record, best_move);
314 if (record_child == 0)
321 int pass_left_child = pass_left;
322 if (best_move.isPass()) --pass_left_child;
330 NtesukiMove::INVALID(),
false);
340 const PathEncoding path_child(path, best_move.getMove());
343 if (result.isUnknown())
349 best_move.getMove());
351 ApplyMoveWithPath<P>::doUndoMoveOrPass(state, path, best_move.getMove(), helper);
365 NtesukiMove::INVALID(),
false);
369 else if (result.isCheckmateFail())
373 move.setCheckmateFail<attacker>(pass_left);
395 NtesukiSimulationSearcher::
398 const unsigned int pass_left,
399 const Move last_move)
402 const Player attacker = P;
408 attackForDisproof<P>(record, record_orig, pass_left, last_move);
410 if (
result.isCheckmateFail())
412 ++disproof_success_count;
423 NtesukiSimulationSearcher::
426 const unsigned int pass_left,
427 const Move last_move)
437 defenseForDisproof<P>(record, record_orig, pass_left, last_move);
439 if (
result.isCheckmateFail())
441 ++disproof_success_count;