10 #include <boost/foreach.hpp>
13 #if (__GNUC__ < 3 || (__GNUC__ ==3 && __GNUC_MINOR__ < 4) ) && defined(USE_GPL_POOL_ALLOCATOR)
14 template class osl::__gnu_cxx::__pool_alloc<true,0>;
18 typedef osl::hash_map<osl::HashKey,list_t>
map_t;
49 : continuous_check(c.continuous_check),
50 hash_history(c.hash_history)
63 const HashKey key(initial);
73 push(
const HashKey& new_key,
bool is_check)
75 const Player last_turn =
alt(new_key.turn());
78 continuous_check[last_turn].push_back(checkCount(last_turn)+1);
82 continuous_check[last_turn].push_back(0);
85 const Table::iterator p=table->find(new_key);
86 if (p == table->end())
88 (*table)[new_key].push_front(
order());
93 l.push_front(
order());
95 hash_history.push(new_key);
99 push(
const HashKey& key,
const NumEffectState& state)
101 const bool is_check = state.inCheck();
106 push(
const NumEffectState& state)
108 push(HashKey(state), state);
115 assert(state.turn() == move.
player());
118 key = key.newHashWithMove(move);
121 using namespace move_classifier;
123 = (!move.
isPass()) && PlayerMoveAdaptor<Check>::isMember(state, move);
131 assert(hash_history.size()>0);
132 const HashKey last_key = hash_history.top();
135 const Player last_turn =
alt(last_key.turn());
136 assert(! continuous_check[last_turn].empty());
137 continuous_check[last_turn].pop_back();
139 const Table::iterator p=table->find(last_key);
140 assert(p != table->end());
143 const list_t::iterator q = p->second.begin();
144 assert(q != p->second.end());
145 assert(*q ==
order());
147 p->second.pop_front();
148 if (p->second.empty())
155 const Table::const_iterator p=table->find(key);
156 if (p == table->end())
158 return p->second.front();
163 const Table::const_iterator p=table->find(key);
164 if (p == table->end())
166 list_t::const_iterator q = p->second.begin();
167 assert(q != p->second.end());
169 while (q != p->second.end())
178 key = key.newHashWithMove(move);
179 const Table::const_iterator p=table->find(key);
180 if (p == table->end())
184 if (p->second.size() < 3)
186 return isAlmostSennichite(key);
192 const Table::const_iterator p=table->find(key);
193 if (p == table->end())
195 return std::make_pair(isAlmostSennichite(key), p->second.size());
201 const Table::const_iterator p=table->find(key);
202 if (p == table->end())
204 return p->second.size();
210 Table::const_iterator p=table->find(key);
211 if (p == table->end())
220 Table::const_iterator p=table->find(key);
221 if (p == table->end())
223 BOOST_FOREACH(
int q, p->second)
225 std::cerr << q <<
" ";
233 HashKeyStack history = hash_history;
234 Table table(*this->table);
235 CArray<osl::vector<int>, 2> continuous_check = this->continuous_check;
236 while (history.empty())
238 const HashKey last_key = history.top();
241 const Player last_turn =
alt(last_key.turn());
242 assert(! continuous_check[last_turn].empty());
243 continuous_check[last_turn].pop_back();
245 const Table::iterator p=table.find(last_key);
246 if (p == table.end())
248 std::cerr <<
"oops, " <<
this <<
"\n";
251 assert(p != table.end());
254 const list_t::iterator q = p->second.begin();
255 assert(q != p->second.end());
256 assert(*q ==
order());
258 p->second.pop_front();
259 if (p->second.empty())
267 #if ! (__GNUC__ >= 4 && __GNUC_MINOR__ >=3)