All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
toAroundKing8Filter.h
Go to the documentation of this file.
1 /* toAroundKing8Filte.h
2  */
3 #ifndef _MOVE_TO_AROUND_KING8_FILTER_H
4 #define _MOVE_TO_AROUND_KING8_FILTER_H
5 #include "osl/square.h"
6 #include "osl/player.h"
7 #include "osl/ptype.h"
10 #include "osl/centering3x3.h"
11 
12 namespace osl
13 {
14  namespace move_action
15  {
16 
22  template<Player P,class OrigAction>
24  {
25  BOOST_CLASS_REQUIRE(OrigAction,osl::move_action,Concept);
26  const NumEffectState& state;
27  OrigAction & action;
29 
30  public:
31  ToAroundKing8Filter(const NumEffectState& s, OrigAction & action)
32  :
33  state(s), action(action),
34  position_king(Centering3x3::adjustCenter(s.template kingSquare<P>()))
35  {
36  }
37 
39  {
40  return to == position_king ||
49  }
50  void simpleMove(Square from,Square to,Ptype ptype, bool isPromote,Player p,Move m){
51  assert(p == P);
52  if(isToAroundKing8Move(to))
53  action.simpleMove(from,to,ptype,isPromote,P,m);
54 
55  }
56  void unknownMove(Square from,Square to,Piece p1,Ptype ptype,bool isPromote,Player p,Move m){
57  assert(p == P);
58  if(isToAroundKing8Move(to))
59  action.unknownMove(from,to,p1,ptype,isPromote,P,m);
60  }
64  void dropMove(Square to,Ptype ptype,Player p,Move m){
65  assert(p == P);
66  if(isToAroundKing8Move(to))
67  action.dropMove(to,ptype,P,m);
68  }
69  // old interfaces
70  void simpleMove(Square from,Square to,Ptype ptype,
71  bool isPromote,Player p)
72  {
73  simpleMove(from,to,ptype,isPromote,p,
74  Move(from,to,ptype,PTYPE_EMPTY,isPromote,p));
75  }
77  Ptype ptype,bool isPromote,Player p)
78  {
79  unknownMove(from,to,captured,ptype,isPromote,p,
80  Move(from,to,ptype,captured.ptype(),isPromote,p));
81  }
82  void dropMove(Square to,Ptype ptype,Player p)
83  {
84  dropMove(to,ptype,p,
85  Move(to,ptype,p));
86  }
87  };
88  } // namespace move_action
89 } // namespace osl
90 
91 #endif /* _MOVE_TO_AROUND_KING8_FILTER_H */
92 // ;;; Local Variables:
93 // ;;; mode:c++
94 // ;;; c-basic-offset:2
95 // ;;; End: