Debian Codegraph @

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

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