00001
00002
00003 #ifndef _GENERATECAPTUREMOVES_TCC
00004 #define _GENERATECAPTUREMOVES_TCC
00005
00006 #include "osl/move_generator/capture_.h"
00007 #include "osl/move_generator/pieceOnBoard.h"
00008 #include "osl/effect_action/alwaysMove.h"
00009 #include "osl/effect_action/betterToPromote.h"
00010 #include "osl/player.h"
00011
00012 namespace osl
00013 {
00014 namespace move_generator
00015 {
00016 using namespace effect_action;
00017 namespace capture
00018 {
00019 template<Player P,class Action>
00020 void generate(const NumEffectState& state,Position target,Action& action,PieceMask pieces)
00021 {
00022 Piece p1=state.getPieceAt(target);
00023 while(pieces.any()){
00024 int num=pieces.takeOneBit();
00025 Piece p=state.getPieceOf(num);
00026 if(state.pinOrOpen(P).test(num) && !state.pinnedCanMoveTo<P>(p,target))
00027 continue;
00028 PieceOnBoard<Action>::template generatePiece<P>(state,p,target,p1,action);
00029 }
00030 }
00031 }
00032
00033 template<class Action>
00034 template<Player P>
00035 void Capture<Action>::
00036 generate(const NumEffectState& state,Position target,Action& action)
00037 {
00038 assert(target.isOnBoard());
00039 PieceMask pieces=state.getOnBoardMask(P)&state.getEffect(target);
00040 capture::generate<P,Action>(state,target,action,pieces);
00041 }
00042
00043 template<class Action>
00044 template<Player P>
00045 void Capture<Action>::
00046 escapeByCapture(const NumEffectState& state,Position target,Piece piece,Action& action)
00047 {
00048 PieceMask pieces=state.getOnBoardMask(P)&state.getEffect(target);
00049 pieces.reset(piece.number());
00050 capture::generate<P,Action>(state,target,action,pieces);
00051 }
00052
00053 }
00054 }
00055
00056 template<class Action>
00057 template<osl::Player P>
00058 void osl::move_generator::Capture<Action>::
00059 generate1(const NumEffectState& state,Position target,
00060 Action& action)
00061 {
00062 Piece move = state.findCheapThreatNotBy(P, target, state.pinOrOpen(P));
00063 if (! move.isPiece())
00064 move = state.findCheapThreat(P, target);
00065 if (move.isPiece())
00066 PieceOnBoard<Action>::template generatePiece<P>
00067 (state,move,target,state.getPieceAt(target),action);
00068 }
00069
00070
00071 #endif
00072
00073
00074
00075