1 #ifndef _GENERATE_DROP_MOVES_TCC
2 #define _GENERATE_DROP_MOVES_TCC
7 namespace move_generator
15 template<Player P,
class Action,
bool hasPawn,
bool hasLance,
bool hasKnight,
int N>
19 assert(hasPawn || hasLance || hasKnight || N>0);
23 Piece p=state.pieceAt(pos);
26 action.dropMove(pos,
ROOK,P);
27 action.dropMove(pos,
BISHOP,P);
28 action.dropMove(pos,
GOLD,P);
29 action.dropMove(pos,
SILVER,P);
32 if(N>=1) action.dropMove(pos,t1,P,m1.
newAddTo(pos));
33 if(N>=2) action.dropMove(pos,t2,P,m2.
newAddTo(pos));
34 if(N>=3) action.dropMove(pos,t3,P,m3.
newAddTo(pos));
38 if(hasPawn || hasLance || N>0){
40 Piece p=state.pieceAt(pos);
43 action.dropMove(pos,
ROOK,P);
44 action.dropMove(pos,
BISHOP,P);
45 action.dropMove(pos,
GOLD,P);
46 action.dropMove(pos,
SILVER,P);
49 if(N>=1) action.dropMove(pos,t1,P,m1.
newAddTo(pos));
50 if(N>=2) action.dropMove(pos,t2,P,m2.
newAddTo(pos));
51 if(N>=3) action.dropMove(pos,t3,P,m3.
newAddTo(pos));
54 action.dropMove(pos,
LANCE,P);
56 action.dropMove(pos,
PAWN,P);
59 for(
int y=3;y<=9;y++){
61 Piece p=state.pieceAt(pos);
64 action.dropMove(pos,
ROOK,P);
65 action.dropMove(pos,
BISHOP,P);
66 action.dropMove(pos,
GOLD,P);
67 action.dropMove(pos,
SILVER,P);
70 if(N>=1) action.dropMove(pos,t1,P,m1.
newAddTo(pos));
71 if(N>=2) action.dropMove(pos,t2,P,m2.
newAddTo(pos));
72 if(N>=3) action.dropMove(pos,t3,P,m3.
newAddTo(pos));
75 action.dropMove(pos,
KNIGHT,P);
77 action.dropMove(pos,
LANCE,P);
79 action.dropMove(pos,
PAWN,P);
86 Piece p=state.pieceAt(pos);
89 action.dropMove(pos,
ROOK,P);
90 action.dropMove(pos,
BISHOP,P);
91 action.dropMove(pos,
GOLD,P);
92 action.dropMove(pos,
SILVER,P);
95 if(N>=1) action.dropMove(pos,t1,P,m1.
newAddTo(pos));
96 if(N>=2) action.dropMove(pos,t2,P,m2.
newAddTo(pos));
97 if(N>=3) action.dropMove(pos,t3,P,m3.
newAddTo(pos));
101 if(hasPawn || hasLance || N>0){
103 Piece p=state.pieceAt(pos);
106 action.dropMove(pos,
ROOK,P);
107 action.dropMove(pos,
BISHOP,P);
108 action.dropMove(pos,
GOLD,P);
109 action.dropMove(pos,
SILVER,P);
112 if(N>=1) action.dropMove(pos,t1,P,m1.
newAddTo(pos));
113 if(N>=2) action.dropMove(pos,t2,P,m2.
newAddTo(pos));
114 if(N>=3) action.dropMove(pos,t3,P,m3.
newAddTo(pos));
117 action.dropMove(pos,
LANCE,P);
119 action.dropMove(pos,
PAWN,P);
122 for(
int y=7;y>=1;y--){
124 Piece p=state.pieceAt(pos);
127 action.dropMove(pos,
ROOK,P);
128 action.dropMove(pos,
BISHOP,P);
129 action.dropMove(pos,
GOLD,P);
130 action.dropMove(pos,
SILVER,P);
133 if(N>=1) action.dropMove(pos,t1,P,m1.
newAddTo(pos));
134 if(N>=2) action.dropMove(pos,t2,P,m2.
newAddTo(pos));
135 if(N>=3) action.dropMove(pos,t3,P,m3.
newAddTo(pos));
138 action.dropMove(pos,
KNIGHT,P);
140 action.dropMove(pos,
LANCE,P);
142 action.dropMove(pos,
PAWN,P);
148 template<Player P,
class Action,
bool hasPawn,
bool hasLance,
bool hasKnight,
int N>
152 if(hasPawn || hasLance || hasKnight || N>0){
154 if(hasLance || hasKnight || N>0){
155 for(
int x=9;x>0;x--){
156 if(state.isPawnMaskSet<P>(x))
157 generateX<P,Action,false,hasLance,hasKnight,N>(state,action,x,m1,m2,m3,t1,t2,t3);
159 generateX<P,Action,true,hasLance,hasKnight,N>(state,action,x,m1,m2,m3,t1,t2,t3);
163 for(
int x=9;x>0;x--){
164 if(!state.isPawnMaskSet<P>(x))
165 generateX<P,Action,true,hasLance,hasKnight,N>(state,action,x,m1,m2,m3,t1,t2,t3);
170 for(
int x=9;x>0;x--){
171 generateX<P,Action,false,hasLance,hasKnight,N>(state,action,x,m1,m2,m3,t1,t2,t3);
178 template<Player P,
class Action,
bool hasPawn,
bool hasLance,
bool hasKnight>
179 static void checkSilver(
const NumEffectState& state,Action& action)
181 if(state.template hasPieceOnStand<SILVER>(P)){
182 if(state.template hasPieceOnStand<GOLD>(P)){
183 if(state.template hasPieceOnStand<BISHOP>(P)){
184 if(state.template hasPieceOnStand<ROOK>(P))
185 generate<P,Action,hasPawn,hasLance,hasKnight,4>(
190 generate<P,Action,hasPawn,hasLance,hasKnight,3>(
197 else if(state.template hasPieceOnStand<ROOK>(P))
198 generate<P,Action,hasPawn,hasLance,hasKnight,3>(
205 generate<P,Action,hasPawn,hasLance,hasKnight,2>(
212 else if(state.template hasPieceOnStand<BISHOP>(P)){
213 if(state.template hasPieceOnStand<ROOK>(P))
214 generate<P,Action,hasPawn,hasLance,hasKnight,3>(
221 generate<P,Action,hasPawn,hasLance,hasKnight,2>(
228 else if(state.template hasPieceOnStand<ROOK>(P))
229 generate<P,Action,hasPawn,hasLance,hasKnight,2>(
236 generate<P,Action,hasPawn,hasLance,hasKnight,1>(
243 else if(state.template hasPieceOnStand<GOLD>(P)){
244 if(state.template hasPieceOnStand<BISHOP>(P)){
245 if(state.template hasPieceOnStand<ROOK>(P))
246 generate<P,Action,hasPawn,hasLance,hasKnight,3>(
253 generate<P,Action,hasPawn,hasLance,hasKnight,2>(
260 else if(state.template hasPieceOnStand<ROOK>(P))
261 generate<P,Action,hasPawn,hasLance,hasKnight,2>(
268 generate<P,Action,hasPawn,hasLance,hasKnight,1>(
275 else if(state.template hasPieceOnStand<BISHOP>(P)){
276 if(state.template hasPieceOnStand<ROOK>(P))
277 generate<P,Action,hasPawn,hasLance,hasKnight,2>(
284 generate<P,Action,hasPawn,hasLance,hasKnight,1>(
291 else if(state.template hasPieceOnStand<ROOK>(P))
292 generate<P,Action,hasPawn,hasLance,hasKnight,1>(
299 generate<P,Action,hasPawn,hasLance,hasKnight,0>(
307 template<Player P,
class Action,
bool hasPawn,
bool hasLance>
308 static void checkKnight(
const NumEffectState& state,Action& action)
310 if(state.template hasPieceOnStand<KNIGHT>(P))
311 checkSilver<P,Action,hasPawn,hasLance,true>(state,action);
313 checkSilver<P,Action,hasPawn,hasLance,false>(state,action);
316 template<Player P,
class Action,
bool hasPawn>
317 static void checkLance(
const NumEffectState& state,Action& action)
319 if(state.template hasPieceOnStand<LANCE>(P))
320 checkKnight<P,Action,hasPawn,true>(state,action);
322 checkKnight<P,Action,hasPawn,false>(state,action);
328 template<
class Action>
329 template<osl::Player P>
331 generate(
const NumEffectState& state,Action& action)
333 if(state.template hasPieceOnStand<PAWN>(P))
334 checkLance<P,Action,true>(state,action);
336 checkLance<P,Action,false>(state,action);