00001
00002
00003 #ifndef _MOVE_ACTION_CHECK_FILTER_H
00004 #define _MOVE_ACTION_CHECK_FILTER_H
00005 #include "osl/position.h"
00006 #include "osl/player.h"
00007 #include "osl/ptype.h"
00008 #include "osl/move_action/concept.h"
00009 #include "osl/move_classifier/check_.h"
00010
00011 namespace osl
00012 {
00013 namespace move_action
00014 {
00015
00020 template<Player P,class State,class OrigAction>
00021 struct CheckFilter
00022 {
00023 BOOST_CLASS_REQUIRE(OrigAction,osl::move_action,Concept);
00024 const State& state;
00025 OrigAction & action;
00026 public:
00027 CheckFilter(const State& s, OrigAction & action)
00028 : state(s), action(action) {
00029 }
00030 void simpleMove(Position from,Position to,Ptype ptype, bool isPromote,Player p){
00031 assert(p == P);
00032 typedef move_classifier::Check<P> check_t;
00033 if(check_t::isDirectCheck(state,ptype,to) ||
00034 move_classifier::OpenCheck<P>::isMember(state,ptype,from,to))
00035 action.simpleMove(from,to,ptype,isPromote,P);
00036 }
00037 void unknownMove(Position from,Position to,Piece p1,Ptype ptype,bool isPromote,Player p){
00038 if(move_classifier::DirectCheck<P>::isMember(state,ptype,to) ||
00039 move_classifier::OpenCheck<P>::isMember(state,ptype,from,to))
00040 action.unknownMove(from,to,p1,ptype,isPromote,P);
00041 }
00042 void dropMove(Position to,Ptype ptype,Player p){
00043 assert(p == P);
00044 if(move_classifier::DirectCheck<P>::isMember(state,ptype,to))
00045 action.dropMove(to,ptype,P);
00046 }
00047 };
00048 }
00049 }
00050
00051 #endif
00052
00053
00054
00055