00001
00002
00003 #ifndef __NTESUKI_SIMULATION_SEARCHER_H
00004 #define __NTESUKI_SIMULATION_SEARCHER_H
00005 #include "osl/ntesuki/ntesukiTable.h"
00006 #include "osl/ntesuki/ntesukiMoveGenerator.h"
00007 #include "ntesukiExceptions.h"
00008
00009 typedef osl::state::NumEffectState state_t;
00010
00011 namespace osl
00012 {
00013 namespace ntesuki
00014 {
00015 class
00016 NtesukiSimulationSearcher
00017 {
00019 unsigned int node_count;
00021 bool verbose;
00022
00024 unsigned int proof_count;
00025 unsigned int proof_success_count;
00026 unsigned int light_proof_success_count;
00027 unsigned int disproof_count;
00028 unsigned int disproof_success_count;
00029 public:
00030 bool debug;
00031 private:
00032 NtesukiResult result;
00033 state_t& state;
00034 NtesukiMoveGenerator *mg;
00035 PathEncoding& path;
00036 NtesukiTable& table;
00037 NtesukiRecord::ISScheme isscheme;
00038
00039
00040
00041
00042 template <class Searcher, Player P> class AttackHelperProof;
00043 template <class Searcher, Player P> class DefenseHelperProof;
00044 template <class Searcher, Player P> class AttackHelperDisproof;
00045 template <class Searcher, Player P> class DefenseHelperDisproof;
00046
00047
00048
00049 template<Player P>
00050 bool
00051 isSafeMove(const Move move,
00052 int pass_left);
00053
00054 template <Player P>
00055 Move
00056 adjustMove(Move candidate) const
00057 {
00058 assert(candidate.isValid());
00059 if (! candidate.isDrop())
00060 {
00061 const Ptype existing = state.getPieceOnBoard(candidate.to()).ptype();
00062 candidate.setCapturePtype(existing);
00063 }
00064 return candidate;
00065 }
00066
00070 template <Player P>
00071 void attackForProof(NtesukiRecord* record,
00072 const NtesukiRecord* record_orig,
00073 const unsigned int passLeft,
00074 const Move last_move);
00078 template <Player P>
00079 void defenseForProof(NtesukiRecord* record,
00080 const NtesukiRecord* record_orig,
00081 const unsigned int passLeft,
00082 const Move last_move);
00086 template <Player P>
00087 void attackForDisproof(NtesukiRecord* record,
00088 const NtesukiRecord* record_orig,
00089 const unsigned int passLeft,
00090 const Move last_move);
00094 template <Player P>
00095 void defenseForDisproof(NtesukiRecord* record,
00096 const NtesukiRecord* record_orig,
00097 const unsigned int passLeft,
00098 const Move last_move);
00099
00100 public:
00101 NtesukiSimulationSearcher(state_t& state,
00102 NtesukiMoveGenerator *mg,
00103 PathEncoding& path,
00104 NtesukiTable& table,
00105 NtesukiRecord::ISScheme isscheme,
00106 bool verbose = false);
00107 ~NtesukiSimulationSearcher();
00108
00113 template <Player P>
00114 bool
00115 startFromAttackProof(NtesukiRecord* record,
00116 const NtesukiRecord* record_orig,
00117 const unsigned int passLeft,
00118 const Move last_move);
00119
00124 template <Player P>
00125 bool
00126 startFromDefenseProof(NtesukiRecord* record,
00127 const NtesukiRecord* record_orig,
00128 const unsigned int passLeft,
00129 const Move last_move);
00130
00135 template <Player P>
00136 bool
00137 startFromAttackDisproof(NtesukiRecord* record,
00138 const NtesukiRecord* record_orig,
00139 const unsigned int passLeft,
00140 const Move last_move);
00141
00146 template <Player P>
00147 bool
00148 startFromDefenseDisproof(NtesukiRecord* record,
00149 const NtesukiRecord* record_orig,
00150 const unsigned int passLeft,
00151 const Move last_move);
00152
00153 unsigned int nodeCount() const { return node_count; }
00154 };
00155 }
00156 }
00157 #endif
00158
00159
00160
00161
00162