All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
escape_.h
Go to the documentation of this file.
1 #ifndef OSL_MOVE_GENERATOR_ESCAPE_H
2 #define OSL_MOVE_GENERATOR_ESCAPE_H
9 #include "osl/effect/liberty8.h"
10 #include "osl/move.h"
11 
12 namespace osl
13 {
14  namespace move_generator
15  {
20  template<class Action>
21  class Escape
22  {
23  // BOOST_CLASS_REQUIRE(Action,osl::move_action,Concept);
24  public:
31  template<Player P,bool CheapOnly>
32  static void generateBlocking(const NumEffectState& state,Piece p,Square to,Square from,Action &action);
39  template<Player P,bool CheapOnly>
40  static void generateBlockingKing(const NumEffectState& state,Piece p,Square from,Action &action);
46  template<Player P>
47  static void generateCaptureKing(const NumEffectState& state,Piece p,Square target,Action& action) {
48  Capture<Action>::template escapeByCapture<P>(state,target,p,action);
49  }
50  template<Player P>
51  static void generateCapture(const NumEffectState& state,Piece p,Square target,Action& action) {
52  Capture<Action>::template escapeByCapture<P>(state,target,p,action);
53  }
54  template<Player P,Ptype Type>
55  static void generateEscape(const NumEffectState& state,Piece p,Action& action,Int2Type<Type>);
56 
60  template<Player P,Ptype Type>
61  static void generateEscape(const NumEffectState& state,Piece p,Action& action){
65  if(Type==KING){
66  assert(p.owner()==P && p.ptype()==KING);
68  generatePtype<P,Type>(state,p,action);
69  }
70  else
71  {
72  typedef move_action::NoEffectFilter<P,Action> CheckAction;
73  CheckAction checkAction(state,action,p.square());
75  generatePtype<P,Type>(state,p,
76  checkAction);
77  }
78  }
79 
80  public:
81  template<Player P,bool cheapOnly>
82  static void generateKingEscape(const NumEffectState& state,Action& action);
83 
87  template<Player P,Ptype Type,bool CheapOnly>
88  static void generateMovesBy(const NumEffectState& state,Piece p,Piece attacker,Action& action);
89  template<Player P,Ptype Type,bool CheapOnly>
90  static void generateMovesBy(const NumEffectState& state,Piece p,Move last_move,Action& action);
91  template<Player P,Ptype Type,bool CheapOnly>
92  static void generateMovesBy(const NumEffectState& state,Piece p,Action& action);
93 
98  template<Player P,bool CheapOnly>
99  static void generateMoves(const NumEffectState& state,Piece piece,Piece attacker,Action& action);
100 
104  template<Player P,bool shouldPromote,bool CheapOnly>
105  static void generate(const NumEffectState& state,Piece piece,Action& action);
106  };
107 
108  template <Player P>
110  {
111  template <class Action>
112  static void generate(const NumEffectState& state, Piece piece, Action& a)
113  {
114  Escape<Action>::template generate<P,true,false>(state, piece, a);
115  }
116  static void generate(const NumEffectState& state, Piece piece, MoveVector& out)
117  {
119  Escape<move_action::Store>::template generate<P,true,false>(state, piece, store);
120  }
121  template <class Action>
122  static void generateCheap(const NumEffectState& state, Piece piece, Action& a)
123  {
124  Escape<Action>::template generate<P,true,true>(state, piece, a);
125  }
126 
127  static void generateCheap(const NumEffectState& state, Piece piece, MoveVector& out)
128  {
130  Escape<move_action::Store>::template generate<P,true,false>(state, piece, store);
131  }
132 
134  template <size_t Capacity>
135  static void generateKingEscape(const NumEffectState& state, FixedCapacityVector<Move,Capacity>& out)
136  {
139  }
140  template <size_t Capacity>
141  static void generateCheapKingEscape(const NumEffectState& state, FixedCapacityVector<Move,Capacity>& out)
142  {
145  }
146  };
148  {
149  template <class Action>
150  static void generate(const NumEffectState& state, Piece piece, Action& a)
151  {
152  if (state.turn() == BLACK)
153  {
154  Escape<Action>::template generate<BLACK,true,false>(state, piece, a);
155  }
156  else
157  {
158  Escape<Action>::template generate<WHITE,true,false>(state, piece, a);
159  }
160  }
161  };
162 
163  } // namespace move_generator
165  {
167  static void generate(const NumEffectState& state, container::MoveVector& out);
168  static void generateCheap(const NumEffectState& state, container::MoveVector& out);
169  };
171 } // namespace osl
172 #endif // OSL_MOVE_GENERATOR_ESCAPE_H
173 // ;;; Local Variables:
174 // ;;; mode:c++
175 // ;;; c-basic-offset:2
176 // ;;; End: