Debian Codegraph @

old-sample/legacy-checkmate/lib/oracleProver.h

raw
1 /* oracleProver.h
2 */
3 #ifndef _ORACLEPROVER_H
4 #define _ORACLEPROVER_H
5
6 #include "proofOracle.h"
7 #include "osl/checkmate/fixedDepthSearcher.h"
8 #include "osl/state/numEffectState.h"
9 #include "osl/hash/hashKey.h"
10 #include "osl/player.h"
11 #include "osl/pathEncoding.h"
12 namespace osl
13 {
14 namespace checkmate
15 {
16 /**
17 * Simulationによる詰の確認.
18 * 攻撃側は類似局面で詰める手のみを試す.
19 */
20 template <class Table>
21 class OracleProver
22 {
23 public:
24 typedef NumEffectState state_t;
25 private:
26 Table& table;
27 state_t *state;
28 HashKey key;
29 PathEncoding path;
30 Player attacker;
31 FixedDepthSearcher fixed_searcher;
32 int node_count;
33 public:
34 explicit OracleProver(Table& t) : table(t), attacker(t.getAttacker()),
35 node_count(0)
36 {
37 }
38 /**
39 * oracle に基づき詰められるかどうかを判定する
40 * @param best_move 詰む場合に詰ます手で上書きする
41 */
42 template <Player Attacker>
43 bool proofWin(state_t& state, const HashKey& key,
44 const PathEncoding& path,
45 ProofOracleAttack<Attacker> oracle,
46 Move& best_move);
47 /**
48 * oracle に基づき詰んでいるかどうかを判定する
49 * @param state に alt(Attacker) に対して王手がかかっていること
50 */
51 template <Player Attacker>
52 bool proofLose(state_t& state, const HashKey& key,
53 const PathEncoding& path,
54 ProofOracleDefense<Attacker> oracle,
55 Move last_move=Move::INVALID());
56
57 int nodeCount() const { return node_count; }
58
59 // private:
60 template <Player P>
61 void attack(CheckHashRecord *record, ProofOracleAttack<P> oracle);
62 template <Player P>
63 void defense(CheckHashRecord *record, ProofOracleDefense<P> oracle);
64 template <Player P>
65 void testFixedDepthAttack(CheckHashRecord *record, Move);
66 template <Player P>
67 void testFixedDepthDefense(CheckHashRecord *record, CheckMove&);
68
69 // テスト兼template instantiation 用途
70 bool proofWin(state_t& state, const PathEncoding& path,
71 const CheckHashRecord *oracle, Move& best_move);
72 bool proofLose(state_t& state, const PathEncoding& path,
73 const CheckHashRecord *oracle, Move last_move=Move::INVALID());
74 };
75
76 } // namespace checkmate
77 } // namespace osl
78
79 #endif /* _ORACLEPROVER_H */
80 // ;;; Local Variables:
81 // ;;; mode:c++
82 // ;;; c-basic-offset:2
83 // ;;; End: