00001
00002
00003 #ifndef MOBILITY_BISHOP_MOBILITY_H
00004 #define MOBILITY_BISHOP_MOBILITY_H
00005 #include "osl/mobility/countMobility.h"
00006
00007 namespace osl
00008 {
00009 namespace mobility
00010 {
00014 struct BishopMobility
00015 {
00016 public:
00024 template<Player P>
00025 static void countBoth(const NumEffectState& state,Piece p,int& countAll,int& countSafe){
00026 assert(p.ptype()==BISHOP || p.ptype()==PBISHOP);
00027 assert(p.isOnBoard());
00028 assert(p.owner()==P);
00029 const Position pos=p.position();
00030 countMobilityBoth<P,true,true>(state,pos,DirectionPlayerTraits<UL,P>::offset(),countAll,countSafe);
00031 countMobilityBoth<P,true,true>(state,pos,DirectionPlayerTraits<UR,P>::offset(),countAll,countSafe);
00032 countMobilityBoth<P,true,true>(state,pos,DirectionPlayerTraits<DL,P>::offset(),countAll,countSafe);
00033 countMobilityBoth<P,true,true>(state,pos,DirectionPlayerTraits<DR,P>::offset(),countAll,countSafe);
00034 }
00035 static void countBoth(Player pl,const NumEffectState& state,Piece p,int& countAll,int& countSafe){
00036 if(pl==BLACK)
00037 countBoth<BLACK>(state,p,countAll,countSafe);
00038 else
00039 countBoth<WHITE>(state,p,countAll,countSafe);
00040 }
00044 template<Player P>
00045 static int countAll(const NumEffectState& state,Piece p){
00046 assert(p.ptype()==BISHOP || p.ptype()==PBISHOP);
00047 assert(p.isOnBoard());
00048 assert(p.owner()==P);
00049 const Position pos=p.position();
00050 return
00051 countMobilityAll(P,state,pos,DirectionPlayerTraits<UL,P>::offset())+
00052 countMobilityAll(P,state,pos,DirectionPlayerTraits<UR,P>::offset())+
00053 countMobilityAll(P,state,pos,DirectionPlayerTraits<DL,P>::offset())+
00054 countMobilityAll(P,state,pos,DirectionPlayerTraits<DR,P>::offset());
00055 }
00056 static int countAll(Player pl,const NumEffectState& state,Piece p){
00057 if(pl==BLACK)
00058 return countAll<BLACK>(state,p);
00059 else
00060 return countAll<WHITE>(state,p);
00061 }
00065 template<Player P>
00066 static int countSafe(const NumEffectState& state,Piece p){
00067 assert(p.ptype()==BISHOP || p.ptype()==PBISHOP);
00068 assert(p.isOnBoard());
00069 assert(p.owner()==P);
00070 const Position pos=p.position();
00071 return
00072 countMobilitySafe(P,state,pos,DirectionPlayerTraits<UL,P>::offset())+
00073 countMobilitySafe(P,state,pos,DirectionPlayerTraits<UR,P>::offset())+
00074 countMobilitySafe(P,state,pos,DirectionPlayerTraits<DL,P>::offset())+
00075 countMobilitySafe(P,state,pos,DirectionPlayerTraits<DR,P>::offset());
00076 }
00077 static int countSafe(Player pl,const NumEffectState& state,Piece p){
00078 if(pl==BLACK)
00079 return countSafe<BLACK>(state,p);
00080 else
00081 return countSafe<WHITE>(state,p);
00082 }
00083 };
00084 }
00085 }
00086 #endif
00087
00088
00089
00090