lanceMobility.h Source File

- Main Page
- Namespaces
- Classes
- Files

- File List
- File Members

All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
lanceMobility.h
Go to the documentation of this file.
1 /* lanceMobility.h
2 */
3 #ifndef MOBILITY_LANCE_MOBILITY_H
4 #define MOBILITY_LANCE_MOBILITY_H
5 #include "osl/mobility/countMobility.h"
6
7 namespace osl
8 {
9 namespace mobility
10 {
14 struct LanceMobility
15 {
16 public:
24 template<Player P>
25 static void countBoth(const NumEffectState& state,Piece p,int& countAll,int& countSafe){
26 assert(p.ptype()==LANCE);
27 assert(p.isOnBoard());
28 assert(p.owner()==P);
29 const Square pos=p.square();
30 countMobilityBoth(P,state,pos,DirectionPlayerTraits<U,P>::offset(),countAll,countSafe);
31 }
32 static void countBoth(Player pl,const NumEffectState& state,Piece p,int& countAll,int &countSafe){
33 if(pl==BLACK)
34 countBoth<BLACK>(state,p,countAll,countSafe);
35 else
36 countBoth<WHITE>(state,p,countAll,countSafe);
37 }
41 template<Player P>
42 static int countAll(const NumEffectState& state,Square pos,int num){
43 const Square pos1=state.mobilityOf(DirectionPlayerTraits<U,P>::directionByBlack,num);
44 int count=(P==BLACK ? pos.y()-pos1.y() : pos1.y()- pos.y())-1+
45 (state.pieceAt(pos1).template canMoveOn<P>() ? 1 : 0);
46 return count;
47 }
48 template<Player P>
49 static int countAll(const NumEffectState& state,Piece p){
50 assert(p.ptype()==LANCE);
51 assert(p.isOnBoard());
52 assert(p.owner()==P);
53 return countAll<P>(state,p.square(),p.number());
54 }
55 static int countAll(Player pl,const NumEffectState& state,Piece p){
56 if(pl==BLACK)
57 return countAll<BLACK>(state,p);
58 else
59 return countAll<WHITE>(state,p);
60 }
64 template<Player P>
65 static int countSafe(const NumEffectState& state,Piece p){
66 assert(p.ptype()==LANCE);
67 assert(p.isOnBoard());
68 assert(p.owner()==P);
69 const Square pos=p.square();
70 return
71 countMobilitySafe(P,state,pos,DirectionPlayerTraits<U,P>::offset());
72 }
73 static int countSafe(Player pl,const NumEffectState& state,Piece p){
74 if(pl==BLACK)
75 return countSafe<BLACK>(state,p);
76 else
77 return countSafe<WHITE>(state,p);
78 }
79 };
80 }
81 }
82 #endif /* MOBILITY_LANCE_MOBILITY_H */
83 // ;;; Local Variables:
84 // ;;; mode:c++
85 // ;;; c-basic-offset:2
86 // ;;; End: