00001
00002
00003 #ifndef MOBILITY_ROOK_MOBILITY_H
00004 #define MOBILITY_ROOK_MOBILITY_H
00005 #include "osl/mobility/countMobility.h"
00006
00007 namespace osl
00008 {
00009 namespace mobility
00010 {
00014 struct RookMobility
00015 {
00016 public:
00024 template<Player P>
00025 static void countVerticalBoth(const NumEffectState& state,Piece p,int& countAll,int& countSafe){
00026 assert(p.ptype()==ROOK || p.ptype()==PROOK);
00027 assert(p.isOnBoard());
00028 assert(p.owner()==P);
00029 const Position pos=p.position();
00030 countMobilityBoth(P,state,pos,DirectionPlayerTraits<U,P>::offset(),countAll,countSafe);
00031 countMobilityBoth(P,state,pos,DirectionPlayerTraits<D,P>::offset(),countAll,countSafe);
00032 }
00033 static void countVerticalBoth(Player pl,const NumEffectState& state,Piece p,int& countAll,int& countSafe){
00034 if(pl==BLACK)
00035 countVerticalBoth<BLACK>(state,p,countAll,countSafe);
00036 else
00037 countVerticalBoth<WHITE>(state,p,countAll,countSafe);
00038 }
00042 template<Player P>
00043 static int countVerticalAll(const NumEffectState& state,Piece p){
00044 const Position pos=p.position();
00045 return
00046 countMobilityAll(P,state,pos,DirectionPlayerTraits<U,P>::offset())+
00047 countMobilityAll(P,state,pos,DirectionPlayerTraits<D,P>::offset());
00048 }
00049 static int countVerticalAll(Player pl,const NumEffectState& state,Piece p){
00050 if(pl==BLACK)
00051 return countVerticalAll<BLACK>(state,p);
00052 else
00053 return countVerticalAll<WHITE>(state,p);
00054 }
00058 template<Player P>
00059 static int countVerticalSafe(const NumEffectState& state,Piece p){
00060 const Position pos=p.position();
00061 return
00062 countMobilitySafe(P,state,pos,DirectionPlayerTraits<U,P>::offset())+
00063 countMobilitySafe(P,state,pos,DirectionPlayerTraits<D,P>::offset());
00064 }
00065 static int countVerticalSafe(Player pl,const NumEffectState& state,Piece p){
00066 if(pl==BLACK)
00067 return countVerticalSafe<BLACK>(state,p);
00068 else
00069 return countVerticalSafe<WHITE>(state,p);
00070 }
00078 template<Player P>
00079 static void countHorizontalBoth(const NumEffectState& state,Piece p,int& countAll,int& countSafe){
00080 assert(p.ptype()==ROOK || p.ptype()==PROOK);
00081 assert(p.isOnBoard());
00082 assert(p.owner()==P);
00083 const Position pos=p.position();
00084 countMobilityBoth(P,state,pos,DirectionPlayerTraits<L,P>::offset(),countAll,countSafe);
00085 countMobilityBoth(P,state,pos,DirectionPlayerTraits<R,P>::offset(),countAll,countSafe);
00086 }
00087 static void countHorizontalBoth(Player pl,const NumEffectState& state,Piece p,int& countAll,int& countSafe){
00088 if(pl==BLACK)
00089 countHorizontalBoth<BLACK>(state,p,countAll,countSafe);
00090 else
00091 countHorizontalBoth<WHITE>(state,p,countAll,countSafe);
00092 }
00096 template<Player P>
00097 static int countHorizontalAll(const NumEffectState& state,Piece p){
00098 const Position pos=p.position();
00099 return
00100 countMobilityAll(P,state,pos,DirectionPlayerTraits<L,P>::offset())+
00101 countMobilityAll(P,state,pos,DirectionPlayerTraits<R,P>::offset());
00102 }
00103 static int countHorizontalAll(Player pl,const NumEffectState& state,Piece p){
00104 if(pl==BLACK)
00105 return countHorizontalAll<BLACK>(state,p);
00106 else
00107 return countHorizontalAll<WHITE>(state,p);
00108 }
00112 template<Player P>
00113 static int countHorizontalSafe(const NumEffectState& state,Piece p){
00114 const Position pos=p.position();
00115 return
00116 countMobilitySafe(P,state,pos,DirectionPlayerTraits<L,P>::offset())+
00117 countMobilitySafe(P,state,pos,DirectionPlayerTraits<R,P>::offset());
00118 }
00119 static int countHorizontalSafe(Player pl,const NumEffectState& state,Piece p){
00120 if(pl==BLACK)
00121 return countHorizontalSafe<BLACK>(state,p);
00122 else
00123 return countHorizontalSafe<WHITE>(state,p);
00124 }
00125 };
00126 }
00127 }
00128 #endif
00129
00130
00131
00132