blockLongEffect.h Source File

- Main Page
- Namespaces
- Classes
- Files

- File List
- File Members

All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
blockLongEffect.h
Go to the documentation of this file.
1 /* blockLongEffect.h
2 */
3 #ifndef _MOVE_CLASSIFIER_BLOCK_LONG_EFFECT_H
4 #define _MOVE_CLASSIFIER_BLOCK_LONG_EFFECT_H
5
6 #include "osl/state/numEffectState.h"
7
8 namespace osl
9 {
10 namespace move_classifier
11 {
17 template<Player P,Ptype T>
18 struct BlockLongEffect
19 {
31 static bool
32 #ifdef __GNUC__
33 __attribute__ ((pure))
34 #endif
35 isMember(NumEffectState const& state,
36 Ptype /*ptype*/,Square /*from*/,Square to)
37 {
38 BOOST_STATIC_ASSERT((PtypeFuns<T>::hasLongMove));
39 if(!state.pieceAt(to).isEmpty())return false;
40 mask_t e1=state.piecesOnBoard(PlayerTraits<P>::opponent).getMask(PtypeFuns<T>::indexNum);
41 mask_t e2=state.effectSetAt(to).getMask(PtypeFuns<T>::indexNum)>>8;
42 mask_t e3=e1 & e2 & mask_t::makeDirect(PtypeFuns<T>::indexMask);
43 while(!e3.none()){
44 int num=e3.takeOneBit()+((PtypeFuns<T>::indexNum)<<5);
45 Piece p=state.pieceOf(num);
46 assert(p.isPiece());
47 assert(p.owner()==PlayerTraits<P>::opponent);
48 assert(unpromote(p.ptype())==T);
49 Offset o=Board_Table.getShortOffset(Offset32(to,p.square()));
50 // EMPTY or Pのpiece or alt(P)のpiece
51 Piece p1=state.pieceAt(to+o);
52 if(! p1.isEdge())
53 return true;
54 }
55 return false;
56 }
57 };
58
59 template<Player P>
60 struct BlockLongAny
61 {
62 static bool isMember(const NumEffectState& state,
63 Ptype ptype,Square from,Square to) {
64 return BlockLongEffect<P,ROOK>::isMember(state, ptype, from, to)
65 || BlockLongEffect<P,BISHOP>::isMember(state, ptype, from, to)
66 || BlockLongEffect<P,LANCE>::isMember(state, ptype, from, to);
67 }
68 };
69 }
70 }
71 #endif /* _MOVE_CLASSIFIER_BLOCK_LONG_EFFECT_H */
72 // ;;; Local Variables:
73 // ;;; mode:c++
74 // ;;; c-basic-offset:2
75 // ;;; End: