blockLongEffect.h
Go to the documentation of this file.
00001 /* blockLongEffect.h
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
00032 #ifdef __GNUC__
00033         __attribute__ ((pure))
00034 #endif
00035       isMember(NumEffectState const& state,
00036                Ptype /*ptype*/,Square /*from*/,Square to)
00037       {
00038         BOOST_STATIC_ASSERT((PtypeFuns<T>::hasLongMove));
00039         if(!state.pieceAt(to).isEmpty())return false;
00040         mask_t e1=state.piecesOnBoard(PlayerTraits<P>::opponent).getMask(PtypeFuns<T>::indexNum);
00041         mask_t e2=state.effectSetAt(to).getMask(PtypeFuns<T>::indexNum)>>8;
00042         mask_t e3=e1 & e2 & mask_t::makeDirect(PtypeFuns<T>::indexMask);
00043         while(!e3.none()){
00044           int num=e3.takeOneBit()+((PtypeFuns<T>::indexNum)<<5);
00045           Piece p=state.pieceOf(num);
00046           assert(p.isPiece());
00047           assert(p.owner()==PlayerTraits<P>::opponent);
00048           assert(unpromote(p.ptype())==T);
00049           Offset o=Board_Table.getShortOffset(Offset32(to,p.square()));
00050           // EMPTY or Pのpiece or alt(P)のpiece
00051           Piece p1=state.pieceAt(to+o);
00052           if(! p1.isEdge())
00053             return true;
00054         }
00055         return false;
00056       }
00057     };
00058 
00059     template<Player P>
00060     struct BlockLongAny
00061     {
00062       static bool isMember(const NumEffectState& state,
00063                            Ptype ptype,Square from,Square to) {
00064         return BlockLongEffect<P,ROOK>::isMember(state, ptype, from, to)
00065           || BlockLongEffect<P,BISHOP>::isMember(state, ptype, from, to)
00066           || BlockLongEffect<P,LANCE>::isMember(state, ptype, from, to);
00067       }
00068     };
00069   }
00070 }
00071 #endif /* _MOVE_CLASSIFIER_BLOCK_LONG_EFFECT_H */
00072 // ;;; Local Variables:
00073 // ;;; mode:c++
00074 // ;;; c-basic-offset:2
00075 // ;;; End:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines