ntesukiSearcher.cc Source File

- Main Page
- Namespaces
- Classes
- Files

- File List
- File Members

All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
ntesukiSearcher.cc
Go to the documentation of this file.
1 #include "osl/ntesuki/ntesukiSearcher.tcc"
2 #include <climits>
3
4 bool osl::ntesuki::NtesukiSearcher::
5 delay_non_pass = false;
6
7 bool osl::ntesuki::NtesukiSearcher::
8 ptt_invalid_defense = false;
9
10 bool osl::ntesuki::NtesukiSearcher::
11 delay_interpose = false;
12
13 bool osl::ntesuki::NtesukiSearcher::
14 delay_nopromote = false;
15
16 bool osl::ntesuki::NtesukiSearcher::
17 delay_non_attack = false;
18
19 bool osl::ntesuki::NtesukiSearcher::
20 read_attack_only = false;
21
22 bool osl::ntesuki::NtesukiSearcher::
23 ptt_non_attack = false;
24
25 bool osl::ntesuki::NtesukiSearcher::
26 ptt_siblings_fail = false;
27
28 bool osl::ntesuki::NtesukiSearcher::
29 ptt_siblings_success = false;
30
31 bool osl::ntesuki::NtesukiSearcher::
32 ptt_uncle = false;
33
34 bool osl::ntesuki::NtesukiSearcher::
35 ptt_aunt = false;
36
37 unsigned int osl::ntesuki::NtesukiSearcher::
38 dynamic_widening_width = 0;
39
40 /* ===================
41 * Constructor / Destructor
42 */
43 osl::ntesuki::NtesukiSearcher::
44 NtesukiSearcher(State& state,
45 NtesukiMoveGenerator *mg,
46 unsigned int table_limit,
47 volatile int *stop_flag,
48 bool verbose,
49 int max_pass,
50 NtesukiRecord::IWScheme iwscheme,
51 NtesukiRecord::PSScheme psscheme,
52 NtesukiRecord::ISScheme isscheme,
53 int tsumero_cost,
54 int tsumero_estimate,
55 double gc_ratio)
56 : state(state),
57 mg(mg),
58 table(table_limit,
59 static_cast<unsigned int>(table_limit * gc_ratio),
60 verbose),
61 simulator(state, mg, path, table, isscheme, verbose),
62 node_count(0),
63 verbose(verbose),
64 stop_flag(stop_flag),
65 path(state.turn()),
66 /* control on search */
67 max_pass(max_pass),
68 iwscheme(iwscheme),
69 psscheme(psscheme),
70 isscheme(isscheme),
71 tsumero_cost(tsumero_cost),
72 tsumero_estimate(tsumero_estimate),
73 gc_ratio(gc_ratio),
74 /* statistical information */
75 blockByAttackBack(0), blockByPass(0),
76 attack_node_count(0),
77 attack_node_under_attack_count(0),
78 attack_node_moves_count(0),
79 defense_node_count(0),
80 defense_node_under_attack_count(0),
81 defense_node_moves_count(0),
82 pass_count(0), pass_success_count(0),
83 pass_attack_count(0), pass_attack_success_count(0),
84 sibling_defense_count(0), sibling_defense_success_count(0),
85 sibling_attack_count(0), sibling_attack_success_count(0),
86 isshogi_defense_count(0), isshogi_defense_success_count(0),
87 isshogi_attack_count(0), isshogi_attack_success_count(0),
88 immediate_win(0), immediate_lose(0),
89 attack_back_count(0),
90 proof_without_inversion_count(0), proof_AND_count(0), disproof_by_inversion_count(0)
91 {
92 NtesukiRecord::table = &table;
93 NtesukiRecord::state = &state;
94 NtesukiRecord::mg = mg;
95 NtesukiRecord::split_count = 0;
96 NtesukiRecord::confluence_count = 0;
97
98 if (this->max_pass > (int)NtesukiRecord::SIZE)
99 this->max_pass = NtesukiRecord::SIZE;
100
101 if (verbose)
102 {
103 std::cerr << "NtesukiSearcher \n"
104 << "IWScheme:\t" << iwscheme << "\n"
105 << "PSScheme:\t" << psscheme << "\n"
106 << "ISScheme:\t" << isscheme << "\n"
107 << "Fixed:\t" << NtesukiRecord::fixed_search_depth<< "\n"
108 << "Tsumero cost:\t" << tsumero_cost << "\n"
109 << "Tsumero estimate:\t" << tsumero_estimate << "\n"
110 << "Inversion cost:\t" << NtesukiRecord::inversion_cost << "\n"
111 ;
112 std::cerr << "enhancements: ";
113 if(NtesukiSearcher::ptt_uncle)
114 std::cerr << " PTT_UNCLE";
115 if(NtesukiSearcher::ptt_siblings_fail)
116 std::cerr << " PTT_SIBLINGS_FAIL";
117 if(NtesukiSearcher::ptt_siblings_success)
118 std::cerr << " PTT_SIBLINGS_SUCCESS";
119 if(NtesukiSearcher::delay_non_pass)
120 std::cerr << " DELAY_NON_PASS";
121 if (NtesukiSearcher::ptt_invalid_defense)
122 std::cerr << " PASS_SIMULATION";
123 if (NtesukiSearcher::delay_interpose)
124 std::cerr << " DELAY_INTERPOSE";
125 if(NtesukiSearcher::delay_nopromote)
126 std::cerr << " DELAY_NOPROMOTE";
127 if(NtesukiSearcher::delay_non_attack)
128 std::cerr << " DELAY_NON_ATTACK";
129 if(NtesukiSearcher::read_attack_only)
130 std::cerr << " READ_ATTACK_ONLY";
131 if(NtesukiSearcher::ptt_non_attack)
132 std::cerr << " PTT_NON_ATTACK";
133 if (NtesukiRecord::use_dominance)
134 std::cerr << " USE_DOMINANCE";
135 std::cerr << "\n";
136 }
137 }
138
139 osl::ntesuki::NtesukiSearcher::
140 ~NtesukiSearcher()
141 {
142 if (verbose)
143 {
144 std::cerr << "~NtesukiSearcher "
145 << table.size()
146 << "/" << node_count
147 << "/" << read_node_limit << "\t"
148 << "pass(" << pass_success_count << "/" << pass_count << ")\n"
149
150 << "attack_node\t"
151 << attack_node_under_attack_count << "/"
152 << attack_node_count << "\t"
153 << attack_node_moves_count << "moves\n"
154
155 << "defense_node\t"
156 << defense_node_under_attack_count << "/"
157 << defense_node_count << "\t"
158 << defense_node_moves_count << "moves\n"
159
160 << "immidate(" << immediate_win << ", "
161 << immediate_lose << ")\n"
162
163 << "attack_back(" << attack_back_count << ")\n"
164
165 << "sibling_success(" << sibling_defense_success_count
166 << "/" << sibling_defense_count << ")\n"
167 << "sibling_fail(" << sibling_attack_success_count
168 << "/" << sibling_attack_count << ")\n"
169
170 << "is_att(" << isshogi_attack_success_count
171 << "/" << isshogi_attack_count << ")\t"
172 << "is_def(" << isshogi_defense_success_count
173 << "/" << isshogi_defense_count << ")\n"
174
175 << "inversion_win(" << disproof_by_inversion_count
176 << "/" << proof_AND_count
177 << "/" << proof_without_inversion_count << ")\n"
178
179 << "DAG\t"
180 << NtesukiRecord::split_count << "/"
181 << NtesukiRecord::confluence_count << "\n"
182 ;
183 }
184 }
185
186 NtesukiTable&
187 osl::ntesuki::NtesukiSearcher::
188 getTable()
189 {
190 return table;
191 }
192
193 /* explicit instantiation
194 */
195 namespace osl
196 {
197 namespace ntesuki
198 {
199 template int NtesukiSearcher::search<BLACK>();
200 template int NtesukiSearcher::search<WHITE>();
201 }
202 }
203
204