00001
00002
00003 #ifndef _MOVE_TO_AROUND_KING24_FILTER_H
00004 #define _MOVE_TO_AROUND_KING24_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/kingOpenMove.h"
00010
00011 namespace osl
00012 {
00013 namespace move_action
00014 {
00015
00019 template<Player P,class OrigAction>
00020 struct ToAroundKing24Filter
00021 {
00022 BOOST_CLASS_REQUIRE(OrigAction,osl::move_action,Concept);
00023 const NumEffectState& state;
00024 OrigAction & action;
00025 Position position_king;
00026
00027 public:
00028 ToAroundKing24Filter(const NumEffectState& s, OrigAction & action)
00029 :
00030 state(s), action(action), position_king(s.template getKingPosition<P>())
00031 {
00032 }
00033
00034 bool isToAroundKing24Move(Position to)
00035 {
00036
00037 return to + Board_Table.getOffsetForBlack(UL)== position_king ||
00038 to + Board_Table.getOffsetForBlack(U)== position_king ||
00039 to + Board_Table.getOffsetForBlack(UR)== position_king ||
00040 to + Board_Table.getOffsetForBlack(L)== position_king ||
00041 to + Board_Table.getOffsetForBlack(R)== position_king ||
00042 to + Board_Table.getOffsetForBlack(DL)== position_king ||
00043 to + Board_Table.getOffsetForBlack(D)== position_king ||
00044 to + Board_Table.getOffsetForBlack(DR)== position_king ||
00045 to + Board_Table.getOffsetForBlack(UL)
00046 + Board_Table.getOffsetForBlack(UL) == position_king ||
00047 to + Board_Table.getOffsetForBlack(UL)
00048 + Board_Table.getOffsetForBlack(U) == position_king ||
00049 to + Board_Table.getOffsetForBlack(U)
00050 + Board_Table.getOffsetForBlack(U) == position_king ||
00051 to + Board_Table.getOffsetForBlack(UR)
00052 + Board_Table.getOffsetForBlack(U) == position_king ||
00053 to + Board_Table.getOffsetForBlack(UR)
00054 + Board_Table.getOffsetForBlack(UR) == position_king ||
00055 to + Board_Table.getOffsetForBlack(UL)
00056 + Board_Table.getOffsetForBlack(L) == position_king ||
00057 to + Board_Table.getOffsetForBlack(UR)
00058 + Board_Table.getOffsetForBlack(R) == position_king ||
00059 to + Board_Table.getOffsetForBlack(L)
00060 + Board_Table.getOffsetForBlack(L) == position_king ||
00061 to + Board_Table.getOffsetForBlack(R)
00062 + Board_Table.getOffsetForBlack(R) == position_king ||
00063 to + Board_Table.getOffsetForBlack(DL)
00064 + Board_Table.getOffsetForBlack(L) == position_king ||
00065 to + Board_Table.getOffsetForBlack(DR)
00066 + Board_Table.getOffsetForBlack(R) == position_king ||
00067 to + Board_Table.getOffsetForBlack(DL)
00068 + Board_Table.getOffsetForBlack(DL) == position_king ||
00069 to + Board_Table.getOffsetForBlack(DL)
00070 + Board_Table.getOffsetForBlack(D) == position_king ||
00071 to + Board_Table.getOffsetForBlack(D)
00072 + Board_Table.getOffsetForBlack(D) == position_king ||
00073 to + Board_Table.getOffsetForBlack(DR)
00074 + Board_Table.getOffsetForBlack(R) == position_king ||
00075 to + Board_Table.getOffsetForBlack(DR)
00076 + Board_Table.getOffsetForBlack(DR) == position_king ||
00077 ;
00078 }
00079 void simpleMove(Position from,Position to,Ptype ptype, bool isPromote,Player p,Move m){
00080 assert(p == P);
00081 if(isToAroundKing24Move(to))
00082 action.simpleMove(from,to,ptype,isPromote,P,m);
00083
00084 }
00085 void unknownMove(Position from,Position to,Piece p1,Ptype ptype,bool isPromote,Player p,Move m){
00086 assert(p == P);
00087 if(isToAroundKing24Move(to))
00088 action.unknownMove(from,to,p1,ptype,isPromote,P,m);
00089 }
00090 void dropMove(Position to,Ptype ptype,Player p,Move m){
00091 assert(p == P);
00092 if(isToAroundKing24Move(to))
00093 action.dropMove(to,ptype,P,m);
00094 }
00095
00096 void simpleMove(Position from,Position to,Ptype ptype,
00097 bool isPromote,Player p)
00098 {
00099 simpleMove(from,to,ptype,isPromote,p,
00100 Move(from,to,ptype,PTYPE_EMPTY,isPromote,p));
00101 }
00102 void unknownMove(Position from,Position to,Piece captured,
00103 Ptype ptype,bool isPromote,Player p)
00104 {
00105 unknownMove(from,to,captured,ptype,isPromote,p,
00106 Move(from,to,ptype,captured.ptype(),isPromote,p));
00107 }
00108 void dropMove(Position to,Ptype ptype,Player p)
00109 {
00110 dropMove(to,ptype,p,
00111 Move(to,ptype,p));
00112 }
00113 };
00114 }
00115 }
00116
00117 #endif
00118
00119
00120
00121