1 #ifndef _EFFECTUTIL_TCC
2 #define _EFFECTUTIL_TCC
8 #include <boost/static_assert.hpp>
14 template <osl::Player P,
bool InterestEmpty, Direction Dir>
17 template <
class State,
class Function>
27 const Piece piece = s.pieceAt(target);
30 if (InterestEmpty || (! piece.
isEmpty()))
33 template <
class State,
class Function>
44 Piece piece = s.pieceAt(target);
49 target = target+offset;
50 piece = s.pieceAt(target);
61 template <osl::Player P,
class Function,
bool InterestEmpty>
87 template <
class Function,
bool InterestEmpty>
94 forEachEffectOfPtypeO<BLACK,Function,InterestEmpty>
97 forEachEffectOfPtypeO<WHITE,Function,InterestEmpty>
115 safe_one = effect_piece;
119 template <osl::Player P>
124 assert(king.
owner() == P);
126 PieceMask ignore = state.pin(P);
127 ignore.set(king.
number());
128 const Piece piece = state.findAttackNotBy(P, target, ignore);
132 state.template forEachEffectNotBy<P>(
target, king, safe_captures);
137 template <
class EvalT>
145 PieceVector& s, PieceVector& u)
146 : state(st),
target(t), attacker_value(a), supported(s), unsupported(u)
151 const Piece cur = state.pieceOnBoard(pos);
155 if (state.hasEffectAt(
target, pos))
157 if (abs(EvalT::captureValue(cur.
ptypeO()))
159 supported.push_back(cur);
163 unsupported.push_back(cur);
168 template <
class EvalT>
169 void osl::EffectUtil::
170 findThreat(
const NumEffectState& state,
Square position,
173 PieceVector supported, unsupported;
174 const int attacker_value = abs(EvalT::captureValue(ptypeo));
176 supported, unsupported);
177 forEachEffectOfPtypeO<FindThreat<EvalT>,
false>
178 (state, position, ptypeo, f);
180 unsupported.sortByPtype();
181 supported.sortByPtype();
182 PieceVector::iterator u=unsupported.begin(), s=supported.begin();
184 if (u!=unsupported.end())
186 while ((s!=supported.end())
187 && ((abs(EvalT::captureValue(s->ptypeO()))
189 > abs(EvalT::captureValue(u->ptypeO()))))
195 out.push_back(u, unsupported.end());
196 out.push_back(s, supported.end());