All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
capture_.tcc
Go to the documentation of this file.
1 /* generateCaptureMoves.tcc
2  */
3 #ifndef _GENERATECAPTUREMOVES_TCC
4 #define _GENERATECAPTUREMOVES_TCC
5 
10 #include "osl/player.h"
11 
12 namespace osl
13 {
14  namespace move_generator
15  {
16  using namespace effect_action;
17  namespace capture
18  {
19  template<Player P,class Action>
20  void generate(const NumEffectState& state,Square target,Action& action,PieceMask pieces)
21  {
22  Piece p1=state.pieceAt(target);
23  while(pieces.any()){
24  int num=pieces.takeOneBit();
25  Piece p=state.pieceOf(num);
26  if(state.pinOrOpen(P).test(num) && !state.pinnedCanMoveTo<P>(p,target))
27  continue;
28  PieceOnBoard<Action>::template generatePiece<P>(state,p,target,p1,action);
29  }
30  }
31  }
32 
33  template<class Action>
34  template<Player P>
36  generate(const NumEffectState& state,Square target,Action& action)
37  {
38  assert(target.isOnBoard());
39  PieceMask pieces=state.piecesOnBoard(P)&state.effectSetAt(target);
40  capture::generate<P,Action>(state,target,action,pieces);
41  }
42 
43  template<class Action>
44  template<Player P>
46  escapeByCapture(const NumEffectState& state,Square target,Piece piece,Action& action)
47  {
48  PieceMask pieces=state.piecesOnBoard(P)&state.effectSetAt(target);
49  pieces.reset(piece.number());
50  capture::generate<P,Action>(state,target,action,pieces);
51  }
52 
53  } // namespace move_generator
54 } // namespace osl
55 
56 template<class Action>
57 template<osl::Player P>
59 generate1(const NumEffectState& state,Square target,
60  Action& action)
61 {
62  Piece move = state.findCheapAttackNotBy(P, target, state.pinOrOpen(P));
63  if (! move.isPiece())
64  move = state.findCheapAttack(P, target);
65  if (move.isPiece())
66  PieceOnBoard<Action>::template generatePiece<P>
67  (state,move,target,state.pieceAt(target),action);
68 }
69 
70 
71 #endif /* _GENERATECAPTUREMOVES_TCC */
72 // ;;; Local Variables:
73 // ;;; mode:c++
74 // ;;; c-basic-offset:2
75 // ;;; End: