1#ifndef _GENERATE_DROP_MOVES_TCC
2#define _GENERATE_DROP_MOVES_TCC
3#include "osl/move_generator/drop.h"
6 namespace move_generator
12 * http://d.hatena.ne.jp/LS3600/200911 2009-11-10 参照
14 template<Player P,class Action,bool hasPawn,bool hasLance,bool hasKnight,int N>
16 generateX(const NumEffectState& state,Action& action,int x,Move m1,Move m2,Move m3,Ptype t1,Ptype t2,Ptype t3)
18 assert(hasPawn || hasLance || hasKnight || N>0);
22 Piece p=state.pieceAt(pos);
25 action.dropMove(pos,ROOK,P);
26 action.dropMove(pos,BISHOP,P);
27 action.dropMove(pos,GOLD,P);
28 action.dropMove(pos,SILVER,P);
31 if(N>=1) action.dropMove(pos,t1,P,m1.newAddTo(pos));
32 if(N>=2) action.dropMove(pos,t2,P,m2.newAddTo(pos));
33 if(N>=3) action.dropMove(pos,t3,P,m3.newAddTo(pos));
37 if(hasPawn || hasLance || N>0){
39 Piece p=state.pieceAt(pos);
42 action.dropMove(pos,ROOK,P);
43 action.dropMove(pos,BISHOP,P);
44 action.dropMove(pos,GOLD,P);
45 action.dropMove(pos,SILVER,P);
48 if(N>=1) action.dropMove(pos,t1,P,m1.newAddTo(pos));
49 if(N>=2) action.dropMove(pos,t2,P,m2.newAddTo(pos));
50 if(N>=3) action.dropMove(pos,t3,P,m3.newAddTo(pos));
53 action.dropMove(pos,LANCE,P);
55 action.dropMove(pos,PAWN,P);
58 for(int y=3;y<=9;y++){
60 Piece p=state.pieceAt(pos);
63 action.dropMove(pos,ROOK,P);
64 action.dropMove(pos,BISHOP,P);
65 action.dropMove(pos,GOLD,P);
66 action.dropMove(pos,SILVER,P);
69 if(N>=1) action.dropMove(pos,t1,P,m1.newAddTo(pos));
70 if(N>=2) action.dropMove(pos,t2,P,m2.newAddTo(pos));
71 if(N>=3) action.dropMove(pos,t3,P,m3.newAddTo(pos));
74 action.dropMove(pos,KNIGHT,P);
76 action.dropMove(pos,LANCE,P);
78 action.dropMove(pos,PAWN,P);
85 Piece p=state.pieceAt(pos);
88 action.dropMove(pos,ROOK,P);
89 action.dropMove(pos,BISHOP,P);
90 action.dropMove(pos,GOLD,P);
91 action.dropMove(pos,SILVER,P);
94 if(N>=1) action.dropMove(pos,t1,P,m1.newAddTo(pos));
95 if(N>=2) action.dropMove(pos,t2,P,m2.newAddTo(pos));
96 if(N>=3) action.dropMove(pos,t3,P,m3.newAddTo(pos));
100 if(hasPawn || hasLance || N>0){
102 Piece p=state.pieceAt(pos);
105 action.dropMove(pos,ROOK,P);
106 action.dropMove(pos,BISHOP,P);
107 action.dropMove(pos,GOLD,P);
108 action.dropMove(pos,SILVER,P);
111 if(N>=1) action.dropMove(pos,t1,P,m1.newAddTo(pos));
112 if(N>=2) action.dropMove(pos,t2,P,m2.newAddTo(pos));
113 if(N>=3) action.dropMove(pos,t3,P,m3.newAddTo(pos));
116 action.dropMove(pos,LANCE,P);
118 action.dropMove(pos,PAWN,P);
121 for(int y=7;y>=1;y--){
123 Piece p=state.pieceAt(pos);
126 action.dropMove(pos,ROOK,P);
127 action.dropMove(pos,BISHOP,P);
128 action.dropMove(pos,GOLD,P);
129 action.dropMove(pos,SILVER,P);
132 if(N>=1) action.dropMove(pos,t1,P,m1.newAddTo(pos));
133 if(N>=2) action.dropMove(pos,t2,P,m2.newAddTo(pos));
134 if(N>=3) action.dropMove(pos,t3,P,m3.newAddTo(pos));
137 action.dropMove(pos,KNIGHT,P);
139 action.dropMove(pos,LANCE,P);
141 action.dropMove(pos,PAWN,P);
147 template<Player P,class Action,bool hasPawn,bool hasLance,bool hasKnight,int N>
149 generate(const NumEffectState& state,Action& action,Move m1,Move m2,Move m3,Ptype t1,Ptype t2,Ptype t3)
151 if(hasPawn || hasLance || hasKnight || N>0){
153 if(hasLance || hasKnight || N>0){
154 for(int x=9;x>0;x--){
155 if(state.isPawnMaskSet<P>(x))
156 generateX<P,Action,false,hasLance,hasKnight,N>(state,action,x,m1,m2,m3,t1,t2,t3);
158 generateX<P,Action,true,hasLance,hasKnight,N>(state,action,x,m1,m2,m3,t1,t2,t3);
162 for(int x=9;x>0;x--){
163 if(!state.isPawnMaskSet<P>(x))
164 generateX<P,Action,true,hasLance,hasKnight,N>(state,action,x,m1,m2,m3,t1,t2,t3);
169 for(int x=9;x>0;x--){
170 generateX<P,Action,false,hasLance,hasKnight,N>(state,action,x,m1,m2,m3,t1,t2,t3);
177 template<Player P,class Action,bool hasPawn,bool hasLance,bool hasKnight>
178 static void checkSilver(const NumEffectState& state,Action& action)
180 if(state.template hasPieceOnStand<SILVER>(P)){
181 if(state.template hasPieceOnStand<GOLD>(P)){
182 if(state.template hasPieceOnStand<BISHOP>(P)){
183 if(state.template hasPieceOnStand<ROOK>(P))
184 generate<P,Action,hasPawn,hasLance,hasKnight,4>(
186 Move::makeDirect(0),Move::makeDirect(0),Move::makeDirect(0),
187 PTYPE_EMPTY,PTYPE_EMPTY,PTYPE_EMPTY);
189 generate<P,Action,hasPawn,hasLance,hasKnight,3>(
191 Move(Square::STAND(),BISHOP,P),
192 Move(Square::STAND(),GOLD,P),
193 Move(Square::STAND(),SILVER,P),
196 else if(state.template hasPieceOnStand<ROOK>(P))
197 generate<P,Action,hasPawn,hasLance,hasKnight,3>(
199 Move(Square::STAND(),ROOK,P),
200 Move(Square::STAND(),GOLD,P),
201 Move(Square::STAND(),SILVER,P),
204 generate<P,Action,hasPawn,hasLance,hasKnight,2>(
206 Move(Square::STAND(),GOLD,P),
207 Move(Square::STAND(),SILVER,P),
209 GOLD,SILVER,PTYPE_EMPTY);
211 else if(state.template hasPieceOnStand<BISHOP>(P)){
212 if(state.template hasPieceOnStand<ROOK>(P))
213 generate<P,Action,hasPawn,hasLance,hasKnight,3>(
215 Move(Square::STAND(),ROOK,P),
216 Move(Square::STAND(),BISHOP,P),
217 Move(Square::STAND(),SILVER,P),
220 generate<P,Action,hasPawn,hasLance,hasKnight,2>(
222 Move(Square::STAND(),BISHOP,P),
223 Move(Square::STAND(),SILVER,P),
225 BISHOP,SILVER,PTYPE_EMPTY);
227 else if(state.template hasPieceOnStand<ROOK>(P))
228 generate<P,Action,hasPawn,hasLance,hasKnight,2>(
230 Move(Square::STAND(),ROOK,P),
231 Move(Square::STAND(),SILVER,P),
233 ROOK,SILVER,PTYPE_EMPTY);
235 generate<P,Action,hasPawn,hasLance,hasKnight,1>(
237 Move(Square::STAND(),SILVER,P),
240 SILVER,PTYPE_EMPTY,PTYPE_EMPTY);
242 else if(state.template hasPieceOnStand<GOLD>(P)){
243 if(state.template hasPieceOnStand<BISHOP>(P)){
244 if(state.template hasPieceOnStand<ROOK>(P))
245 generate<P,Action,hasPawn,hasLance,hasKnight,3>(
247 Move(Square::STAND(),ROOK,P),
248 Move(Square::STAND(),BISHOP,P),
249 Move(Square::STAND(),GOLD,P),
252 generate<P,Action,hasPawn,hasLance,hasKnight,2>(
254 Move(Square::STAND(),BISHOP,P),
255 Move(Square::STAND(),GOLD,P),
257 BISHOP,GOLD,PTYPE_EMPTY);
259 else if(state.template hasPieceOnStand<ROOK>(P))
260 generate<P,Action,hasPawn,hasLance,hasKnight,2>(
262 Move(Square::STAND(),ROOK,P),
263 Move(Square::STAND(),GOLD,P),
265 ROOK,GOLD,PTYPE_EMPTY);
267 generate<P,Action,hasPawn,hasLance,hasKnight,1>(
269 Move(Square::STAND(),GOLD,P),
272 GOLD,PTYPE_EMPTY,PTYPE_EMPTY);
274 else if(state.template hasPieceOnStand<BISHOP>(P)){
275 if(state.template hasPieceOnStand<ROOK>(P))
276 generate<P,Action,hasPawn,hasLance,hasKnight,2>(
278 Move(Square::STAND(),ROOK,P),
279 Move(Square::STAND(),BISHOP,P),
281 ROOK,BISHOP,PTYPE_EMPTY);
283 generate<P,Action,hasPawn,hasLance,hasKnight,1>(
285 Move(Square::STAND(),BISHOP,P),
288 BISHOP,PTYPE_EMPTY,PTYPE_EMPTY);
290 else if(state.template hasPieceOnStand<ROOK>(P))
291 generate<P,Action,hasPawn,hasLance,hasKnight,1>(
293 Move(Square::STAND(),ROOK,P),
296 ROOK,PTYPE_EMPTY,PTYPE_EMPTY);
298 generate<P,Action,hasPawn,hasLance,hasKnight,0>(
303 PTYPE_EMPTY,PTYPE_EMPTY,PTYPE_EMPTY);
306 template<Player P,class Action,bool hasPawn,bool hasLance>
307 static void checkKnight(const NumEffectState& state,Action& action)
309 if(state.template hasPieceOnStand<KNIGHT>(P))
310 checkSilver<P,Action,hasPawn,hasLance,true>(state,action);
312 checkSilver<P,Action,hasPawn,hasLance,false>(state,action);
315 template<Player P,class Action,bool hasPawn>
316 static void checkLance(const NumEffectState& state,Action& action)
318 if(state.template hasPieceOnStand<LANCE>(P))
319 checkKnight<P,Action,hasPawn,true>(state,action);
321 checkKnight<P,Action,hasPawn,false>(state,action);
325 using drop::checkLance;
327 template<class Action>
328 template<osl::Player P>
329 void osl::move_generator::Drop<Action>::
330 generate(const NumEffectState& state,Action& action)
332 if(state.template hasPieceOnStand<PAWN>(P))
333 checkLance<P,Action,true>(state,action);
335 checkLance<P,Action,false>(state,action);
337 } // namespace move_generator
340#endif /* _GENERATE_DROP_MOVES_TCC */
341// ;;; Local Variables:
343// ;;; c-basic-offset:2