00001
00002
00003 #ifndef _MOVE_CLASSIFIER_BLOCK_LONG_EFFECT_H
00004 #define _MOVE_CLASSIFIER_BLOCK_LONG_EFFECT_H
00005
00006 #include "osl/state/numEffectState.h"
00007
00008 namespace osl
00009 {
00010 namespace move_classifier
00011 {
00017 template<Player P,Ptype T>
00018 struct BlockLongEffect
00019 {
00031 static bool isMember(NumEffectState const& state,
00032 Ptype ,Position ,Position to){
00033 BOOST_STATIC_ASSERT((PtypeFuns<T>::hasLongMove));
00034 if(!state.getPieceAt(to).isEmpty())return false;
00035 mask_t e1=state.getOnBoardMask(PlayerTraits<P>::opponent).getMask(PtypeFuns<T>::indexNum);
00036 mask_t e2=state.getEffect(to).getMask(PtypeFuns<T>::indexNum)>>8;
00037 mask_t e3=e1 & e2 & mask_t::makeDirect(PtypeFuns<T>::indexMask);
00038 while(!e3.none()){
00039 int num=e3.takeOneBit()+((PtypeFuns<T>::indexNum)<<5);
00040 Piece p=state.getPieceOf(num);
00041 assert(p.isPiece());
00042 assert(p.owner()==PlayerTraits<P>::opponent);
00043 assert(unpromote(p.ptype())==T);
00044 Offset o=Board_Table.getShortOffset(Offset32(to,p.position()));
00045
00046 Piece p1=state.getPieceAt(to+o);
00047 if(! p1.isEdge())
00048 return true;
00049 }
00050 return false;
00051 }
00052 };
00053
00054 template<Player P>
00055 struct BlockLongAny
00056 {
00057 static bool isMember(const NumEffectState& state,
00058 Ptype ptype,Position from,Position to) {
00059 return BlockLongEffect<P,ROOK>::isMember(state, ptype, from, to)
00060 || BlockLongEffect<P,BISHOP>::isMember(state, ptype, from, to)
00061 || BlockLongEffect<P,LANCE>::isMember(state, ptype, from, to);
00062 }
00063 };
00064 }
00065 }
00066 #endif
00067
00068
00069
00070