Go to the documentation of this file.00001 #ifndef _MOVE_GENERATOR_ATTACK_TO_PINNED_TCC
00002 #define _MOVE_GENERATOR_ATTACK_TO_PINNED_TCC
00003 #include "osl/move_generator/attackToPinned.h"
00004 #include "osl/ptypeTable.h"
00005 #include "osl/effectContent.h"
00006 #include "osl/move_generator/addEffectWithEffect.h"
00007 #include "osl/misc/loki.h"
00008
00009 namespace osl
00010 {
00011 namespace move_generator
00012 {
00013 namespace {
00014 template<Player P,Ptype T,class Action>
00015 void generatePtype(const NumEffectState& state,Action& action)
00016 {
00017 Square target=state.template kingSquare<PlayerTraits<P>::opponent>();
00018 for(int num=PtypeTraits<T>::indexMin;num<PtypeTraits<T>::indexLimit;num++){
00019 Piece p=state.pieceOf(num);
00020 if(p.template isOnBoardByOwner<P>()){
00021 Square from=p.square();
00022 EffectContent effect=Ptype_Table.getEffect(newPtypeO(P,T),from,target);
00023 if(effect.hasEffect()){
00024 Offset offset=effect.offset();
00025 assert(!offset.zero());
00026 Piece p1;
00027 Square pos=target-offset;
00028 for(;(p1=state.pieceAt(pos)).isEmpty();pos-=offset) ;
00029 if(p1.canMoveOn<P>() &&
00030 state.hasEffectByPiece(p,pos)){
00031 AddEffectWithEffect<Action>::template generate<P,false>(state,pos,action);
00032 }
00033 }
00034 }
00035 }
00036 }
00037 }
00038 template<Player P>
00039 template<class Action>
00040 void AttackToPinned<P>::
00041 generate(const NumEffectState& state,Action& action)
00042 {
00043 generatePtype<P,ROOK,Action>(state,action);
00044 generatePtype<P,BISHOP,Action>(state,action);
00045 generatePtype<P,LANCE,Action>(state,action);
00046 }
00047
00048 }
00049 }
00050
00051 #endif
00052
00053
00054
00055