notKingOpenFilter.h Source File

- Main Page
- Namespaces
- Classes
- Files

- File List
- File Members

All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
notKingOpenFilter.h
Go to the documentation of this file.
1 /* notKingOpenFilter.h
2 */
3 #ifndef _MOVE_ACTION_NOT_KING_OPEN_FILTER_H
4 #define _MOVE_ACTION_NOT_KING_OPEN_FILTER_H
5 #include "osl/square.h"
6 #include "osl/player.h"
7 #include "osl/ptype.h"
8 #include "osl/move_action/concept.h"
9 #include "osl/move_classifier/kingOpenMove.h"
10
11 namespace osl
12 {
13 namespace move_action
14 {
15
19 template<Player P,class OrigAction>
20 struct NotKingOpenFilter
21 {
22 BOOST_CLASS_REQUIRE(OrigAction,osl::move_action,Concept);
23 const NumEffectState& state;
24 OrigAction & action;
25 public:
26 NotKingOpenFilter(const NumEffectState& s, OrigAction & action)
27 : state(s), action(action) {
28 }
29 bool isNotKingOpenMove(Ptype ptype,Square from,Square to)
30 {
31 return !move_classifier::KingOpenMove<P>::isMember(state, ptype, from, to);
32 }
33 void simpleMove(Square from,Square to,Ptype ptype, bool isPromote,Player
34 #ifndef NDEBUG
35 p
36 #endif
37 ,Move m
38 ){
39 assert(p == P);
40 if(isNotKingOpenMove(ptype,from,to))
41 action.simpleMove(from,to,ptype,isPromote,P,m);
42
43 }
44 void unknownMove(Square from,Square to,Piece p1,Ptype ptype,bool isPromote,Player
45 #ifndef NDEBUG
46 p
47 #endif
48 ,Move m
49 ){
50 assert(p == P);
51 if(isNotKingOpenMove(ptype,from,to))
52 action.unknownMove(from,to,p1,ptype,isPromote,P,m);
53 }
57 void dropMove(Square to,Ptype ptype,Player
58 #ifndef NDEBUG
59 p
60 #endif
61 ,Move m
62 ){
63 assert(p == P);
64 action.dropMove(to,ptype,P,m);
65 }
66 // old interfaces
67 void simpleMove(Square from,Square to,Ptype ptype,
68 bool isPromote,Player p)
69 {
70 simpleMove(from,to,ptype,isPromote,p,
71 Move(from,to,ptype,PTYPE_EMPTY,isPromote,p));
72 }
73 void unknownMove(Square from,Square to,Piece captured,
74 Ptype ptype,bool isPromote,Player p)
75 {
76 unknownMove(from,to,captured,ptype,isPromote,p,
77 Move(from,to,ptype,captured.ptype(),isPromote,p));
78 }
79 void dropMove(Square to,Ptype ptype,Player p)
80 {
81 dropMove(to,ptype,p,
82 Move(to,ptype,p));
83 }
84 };
85 } // namespace move_action
86 } // namespace osl
87
88 #endif /* _MOVE_ACTION_NOT_KING_OPEN_FILTER_H */
89 // ;;; Local Variables:
90 // ;;; mode:c++
91 // ;;; c-basic-offset:2
92 // ;;; End: