Debian Codegraph @

old-sample/legacy-checkmate/lib/checkStack.cc

raw
1 /* checkStack.cc
2 */
3 #include "checkStack.h"
4 #include "checkHashRecord.h"
5 #include "osl/record/csa.h"
6 #include <iostream>
7
8 osl::checkmate::CheckStackEntry::
9 CheckStackEntry(const CheckMove *nextMove, const char *name,
10 const CheckHashRecord *r,
11 const HashKey& h, const PathEncoding& path,
12 unsigned int proofLimit, unsigned int disproofLimit)
13 : move(nextMove ? *nextMove : CheckMove()),
14 name(name), record(r), hash(h), path(path),
15 proofLimit(proofLimit), disproofLimit(disproofLimit)
16 {
17 }
18
19
20 osl::checkmate::CheckStack::
21 ~CheckStack()
22 {
23 }
24
25 osl::checkmate::CheckStack::const_iterator osl::checkmate::CheckStack::
26 findLoop(const CheckHashRecord *record) const
27 {
28 for (const_iterator p=begin(); p!=end(); ++p)
29 {
30 if (p->record == record)
31 return p;
32 }
33 return end();
34 }
35
36 osl::checkmate::CheckStack::const_iterator osl::checkmate::CheckStack::
37 findCover(Player attacker, const HashKey& hash, const CheckHashRecord *record) const
38 {
39 for (const_iterator p=begin(); p!=end(); ++p)
40 {
41 assert(p->record);
42 if (! p->hash.isSameBoard(hash))
43 continue;
44 if (p->record->stand(BLACK).hasMoreThan(attacker, record->stand(BLACK))
45 && (p->record->stand(BLACK) != record->stand(BLACK)))
46 return p;
47 }
48 return end();
49 }
50
51 #ifndef MINIMAL
52 std::ostream& osl::checkmate::
53 operator<<(std::ostream& os, const CheckStack& s)
54 {
55 for (size_t i=0; i<s.size(); ++i)
56 {
57 std::cerr << i << " " << s[i] << "\n";
58 }
59 return os;
60 }
61
62 std::ostream& osl::checkmate::
63 operator<<(std::ostream& os, const CheckStackEntry& e)
64 {
65 csaShow(os, e.move.move);
66 // os << e.move.move;
67 os << " " << e.move.flags << " " << e.name << " " << e.record
68 << " " << e.path;
69 if (e.proofLimit)
70 os << " pl" << e.proofLimit;
71 if (e.disproofLimit)
72 os << " dl" << e.disproofLimit;
73 if (e.record)
74 {
75 os << " depth " << e.record->distance
76 // << " " << e.record->proofDisproof()
77 << " m " << e.record->moves.size();
78 #if 0
79 // TODO: 内訳
80 << " s " << e.record->solvedMoves.size()
81 << " u " << e.record->upwardMoves.size();
82 if (e.record->interposeMoves.size())
83 os << " i " << e.record->interposeMoves.size();
84 if (e.record->noPromoteMoves.size())
85 os << " n " << e.record->noPromoteMoves.size();
86 #endif
87 os << " p " << e.record->proof()
88 << " d " << e.record->disproof()
89 << " " << e.record->filter;
90 if (e.record->finalByDominance())
91 os << " dom by " << e.record->finalByDominance();
92 if (! e.record->twins.empty())
93 {
94 os << " twins " << e.record->twins.size();
95 for (TwinList::const_iterator p=e.record->twins.begin();
96 p!=e.record->twins.end(); ++p)
97 {
98 os << " " << p->path << " ";
99 csaShow(os, p->move.move);
100 }
101 }
102 }
103 return os;
104 }
105 #endif
106 /* ------------------------------------------------------------------------- */
107 // ;;; Local Variables:
108 // ;;; mode:c++
109 // ;;; c-basic-offset:2
110 // ;;; End: