00001
00002
00003 #ifndef _MOVE_TO_AROUND_KING8_FILTER_H
00004 #define _MOVE_TO_AROUND_KING8_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 #include "osl/centering3x3.h"
00011
00012 namespace osl
00013 {
00014 namespace move_action
00015 {
00016
00022 template<Player P,class OrigAction>
00023 struct ToAroundKing8Filter : public MoveAction
00024 {
00025 BOOST_CLASS_REQUIRE(OrigAction,osl::move_action,Concept);
00026 const NumEffectState& state;
00027 OrigAction & action;
00028 Position position_king;
00029
00030 public:
00031 ToAroundKing8Filter(const NumEffectState& s, OrigAction & action)
00032 :
00033 state(s), action(action),
00034 position_king(Centering3x3::adjustCenter(s.template getKingPosition<P>()))
00035 {
00036 }
00037
00038 bool isToAroundKing8Move(Position to)
00039 {
00040 return to == position_king ||
00041 to + Board_Table.getOffsetForBlack(UL)== position_king ||
00042 to + Board_Table.getOffsetForBlack(U)== position_king ||
00043 to + Board_Table.getOffsetForBlack(UR)== position_king ||
00044 to + Board_Table.getOffsetForBlack(L)== position_king ||
00045 to + Board_Table.getOffsetForBlack(R)== position_king ||
00046 to + Board_Table.getOffsetForBlack(DL)== position_king ||
00047 to + Board_Table.getOffsetForBlack(D)== position_king ||
00048 to + Board_Table.getOffsetForBlack(DR)== position_king;
00049 }
00050 void simpleMove(Position from,Position to,Ptype ptype, bool isPromote,Player p,Move m){
00051 assert(p == P);
00052 if(isToAroundKing8Move(to))
00053 action.simpleMove(from,to,ptype,isPromote,P,m);
00054
00055 }
00056 void unknownMove(Position from,Position to,Piece p1,Ptype ptype,bool isPromote,Player p,Move m){
00057 assert(p == P);
00058 if(isToAroundKing8Move(to))
00059 action.unknownMove(from,to,p1,ptype,isPromote,P,m);
00060 }
00064 void dropMove(Position to,Ptype ptype,Player p,Move m){
00065 assert(p == P);
00066 if(isToAroundKing8Move(to))
00067 action.dropMove(to,ptype,P,m);
00068 }
00069
00070 void simpleMove(Position from,Position to,Ptype ptype,
00071 bool isPromote,Player p)
00072 {
00073 simpleMove(from,to,ptype,isPromote,p,
00074 Move(from,to,ptype,PTYPE_EMPTY,isPromote,p));
00075 }
00076 void unknownMove(Position from,Position to,Piece captured,
00077 Ptype ptype,bool isPromote,Player p)
00078 {
00079 unknownMove(from,to,captured,ptype,isPromote,p,
00080 Move(from,to,ptype,captured.ptype(),isPromote,p));
00081 }
00082 void dropMove(Position to,Ptype ptype,Player p)
00083 {
00084 dropMove(to,ptype,p,
00085 Move(to,ptype,p));
00086 }
00087 };
00088 }
00089 }
00090
00091 #endif
00092
00093
00094
00095