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