00001
00002
00003 #ifndef _MOVE_ACTION_NOT_KING_OPEN_FILTER_H
00004 #define _MOVE_ACTION_NOT_KING_OPEN_FILTER_H
00005 #include "osl/square.h"
00006 #include "osl/player.h"
00007 #include "osl/ptype.h"
00008 #include "osl/move_action/concept.h"
00009 #include "osl/move_classifier/kingOpenMove.h"
00010
00011 namespace osl
00012 {
00013 namespace move_action
00014 {
00015
00019 template<Player P,class OrigAction>
00020 struct NotKingOpenFilter
00021 {
00022 BOOST_CLASS_REQUIRE(OrigAction,osl::move_action,Concept);
00023 const NumEffectState& state;
00024 OrigAction & action;
00025 public:
00026 NotKingOpenFilter(const NumEffectState& s, OrigAction & action)
00027 : state(s), action(action) {
00028 }
00029 bool isNotKingOpenMove(Ptype ptype,Square from,Square to)
00030 {
00031 return !move_classifier::KingOpenMove<P>::isMember(state, ptype, from, to);
00032 }
00033 void simpleMove(Square from,Square to,Ptype ptype, bool isPromote,Player
00034 #ifndef NDEBUG
00035 p
00036 #endif
00037 ,Move m
00038 ){
00039 assert(p == P);
00040 if(isNotKingOpenMove(ptype,from,to))
00041 action.simpleMove(from,to,ptype,isPromote,P,m);
00042
00043 }
00044 void unknownMove(Square from,Square to,Piece p1,Ptype ptype,bool isPromote,Player
00045 #ifndef NDEBUG
00046 p
00047 #endif
00048 ,Move m
00049 ){
00050 assert(p == P);
00051 if(isNotKingOpenMove(ptype,from,to))
00052 action.unknownMove(from,to,p1,ptype,isPromote,P,m);
00053 }
00057 void dropMove(Square to,Ptype ptype,Player
00058 #ifndef NDEBUG
00059 p
00060 #endif
00061 ,Move m
00062 ){
00063 assert(p == P);
00064 action.dropMove(to,ptype,P,m);
00065 }
00066
00067 void simpleMove(Square from,Square to,Ptype ptype,
00068 bool isPromote,Player p)
00069 {
00070 simpleMove(from,to,ptype,isPromote,p,
00071 Move(from,to,ptype,PTYPE_EMPTY,isPromote,p));
00072 }
00073 void unknownMove(Square from,Square to,Piece captured,
00074 Ptype ptype,bool isPromote,Player p)
00075 {
00076 unknownMove(from,to,captured,ptype,isPromote,p,
00077 Move(from,to,ptype,captured.ptype(),isPromote,p));
00078 }
00079 void dropMove(Square to,Ptype ptype,Player p)
00080 {
00081 dropMove(to,ptype,p,
00082 Move(to,ptype,p));
00083 }
00084 };
00085 }
00086 }
00087
00088 #endif
00089
00090
00091
00092