説明を見る。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/move_generator/effect_action.h"
00009 #include "osl/basic_type.h"
00010
00011 namespace osl
00012 {
00013 namespace move_generator
00014 {
00015 using namespace effect_action;
00016 namespace capture
00017 {
00018 template<Player P,class Action>
00019 void generate(const NumEffectState& state,Square target,Action& action,PieceMask pieces)
00020 {
00021 Piece p1=state.pieceAt(target);
00022 while(pieces.any()){
00023 int num=pieces.takeOneBit();
00024 Piece p=state.pieceOf(num);
00025 if(state.pinOrOpen(P).test(num) && !state.pinnedCanMoveTo<P>(p,target))
00026 continue;
00027 PieceOnBoard<Action>::template generatePiece<P>(state,p,target,p1,action);
00028 }
00029 }
00030 }
00031
00032 template<class Action>
00033 template<Player P>
00034 void Capture<Action>::
00035 generate(const NumEffectState& state,Square target,Action& action)
00036 {
00037 assert(target.isOnBoard());
00038 PieceMask pieces=state.piecesOnBoard(P)&state.effectSetAt(target);
00039 capture::generate<P,Action>(state,target,action,pieces);
00040 }
00041
00042 template<class Action>
00043 template<Player P>
00044 void Capture<Action>::
00045 escapeByCapture(const NumEffectState& state,Square target,Piece piece,Action& action)
00046 {
00047 PieceMask pieces=state.piecesOnBoard(P)&state.effectSetAt(target);
00048 pieces.reset(piece.number());
00049 capture::generate<P,Action>(state,target,action,pieces);
00050 }
00051
00052 }
00053 }
00054
00055 template<class Action>
00056 template<osl::Player P>
00057 void osl::move_generator::Capture<Action>::
00058 generate1(const NumEffectState& state,Square target,
00059 Action& action)
00060 {
00061 Piece move = state.findCheapAttackNotBy(P, target, state.pinOrOpen(P));
00062 if (! move.isPiece())
00063 move = state.findCheapAttack(P, target);
00064 if (move.isPiece())
00065 PieceOnBoard<Action>::template generatePiece<P>
00066 (state,move,target,state.pieceAt(target),action);
00067 }
00068
00069
00070 #endif
00071
00072
00073
00074