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 State,class OrigAction>
00023 struct ToAroundKing8Filter
00024 {
00025 BOOST_CLASS_REQUIRE(OrigAction,osl::move_action,Concept);
00026 const State& state;
00027 OrigAction & action;
00028 Position position_king;
00029
00030 public:
00031 ToAroundKing8Filter(const State& 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){
00051 assert(p == P);
00052 if(isToAroundKing8Move(to))
00053 action.simpleMove(from,to,ptype,isPromote,P);
00054
00055 }
00056 void unknownMove(Position from,Position to,Piece p1,Ptype ptype,bool isPromote,Player p){
00057 assert(p == P);
00058 if(isToAroundKing8Move(to))
00059 action.unknownMove(from,to,p1,ptype,isPromote,P);
00060 }
00064 void dropMove(Position to,Ptype ptype,Player p){
00065 assert(p == P);
00066 if(isToAroundKing8Move(to))
00067 action.dropMove(to,ptype,P);
00068 }
00069 };
00070 }
00071 }
00072
00073 #endif
00074
00075
00076
00077