Debian Codegraph @

old-sample/legacy-checkmate/lib/analyzer/checkTableAnalyzer.h

raw
1 /* checkTableAnalyzer.h
2 */
3 #ifndef _CHECKTABLEANALYZER_H
4 #define _CHECKTABLEANALYZER_H
5
6 #include <iosfwd>
7 #include <cstddef>
8 namespace osl
9 {
10 namespace hash
11 {
12 class HashKey;
13 }
14 class PathEncoding;
15 namespace checkmate
16 {
17 class CheckHashRecord;
18 class TwinTable;
19 namespace analyzer
20 {
21 using hash::HashKey;
22 /**
23 * 詰将棋探索後のテーブルの分析
24 *
25 * 探索した木の大きさと、見つけた証明に必要な木の大きさ
26 * (最小証明木とは限らない)、
27 * TODO: 証明に必要な持駒などを求める
28 */
29 class CheckTableAnalyzer
30 {
31 const TwinTable& table;
32 bool useOutlineFormat;
33 public:
34 explicit CheckTableAnalyzer(const TwinTable&, bool outline=true);
35 ~CheckTableAnalyzer();
36
37 /**
38 * record を root とする木を書き出す
39 */
40 void showTree(const CheckHashRecord *record, std::ostream& os,
41 int maxDepth, bool expandFinalState=true,
42 bool showTerminalMoves=false, size_t threshold=0) const;
43 /**
44 * テーブルの中でstate から到達可能な局面の数を調べる
45 */
46 size_t treeSize(const CheckHashRecord *record) const;
47 /**
48 * record の証明するのに必要な局面の数を調べる
49 */
50 size_t proofTreeSize(const CheckHashRecord *record,
51 const HashKey& key,
52 const PathEncoding& path,
53 bool orNode) const;
54 size_t proofTreeSize(const CheckHashRecord *record,
55 const HashKey& key,
56 const PathEncoding& path,
57 bool orNode, size_t &leaf_size) const;
58 /**
59 * record の反証するのに必要な局面の数を調べる
60 */
61 size_t disproofTreeSize(const CheckHashRecord *record,
62 const HashKey& key,
63 const PathEncoding& path,
64 bool orNode, bool isPartialStack=false) const;
65 size_t disproofTreeSize(const CheckHashRecord *record,
66 const HashKey& key,
67 const PathEncoding& path,
68 bool orNode, size_t& leaf_size,
69 bool isPartialStack=false) const;
70 /**
71 * @return state が 詰みでも不詰でもなければ 0 が帰る
72 */
73 size_t proofOrDisproofTreeSize(const CheckHashRecord *record,
74 const HashKey& key,
75 const PathEncoding& path,
76 bool orNode, bool isPartialStack=false) const;
77 size_t proofOrDisproofTreeSize(const CheckHashRecord *record,
78 const HashKey& key,
79 const PathEncoding& path,
80 bool orNode, size_t& leaf_size,
81 bool isPartialStack=false) const;
82
83 /**
84 * テーブルの中でstate の証明するのに必要な木を表示する
85 */
86 size_t showProofTree(const CheckHashRecord *record,
87 const HashKey& key, const PathEncoding& path,
88 bool orNode, std::ostream& os,
89 bool isPartialStack=false) const;
90 };
91 } // namespace analyzer
92 } // namespace checkmate
93 using checkmate::analyzer::CheckTableAnalyzer;
94 } // namespace osl
95
96 #endif /* _CHECKTABLEANALYZER_H */
97 // ;;; Local Variables:
98 // ;;; mode:c++
99 // ;;; c-basic-offset:2
100 // ;;; End: