4 b_gen_drop( tree_t * restrict __ptree__, unsigned int * restrict pmove )
6 const tree_t * restrict ptree = __ptree__;
8 unsigned int ihand, ibb_target0a, ibb_target0b, ibb_pawn_cmp, utemp;
9 unsigned int ais_pawn[nfile];
10 int nhand, ito, i, nolance, noknight;
13 if ( ! HAND_B ) { return pmove; } /* return! */
16 if ( IsHandKnight( ihand ) ) { ahand[ nhand++ ] = Drop2Move(knight); }
18 if ( IsHandLance( ihand ) ) { ahand[ nhand++ ] = Drop2Move(lance); }
20 if ( IsHandSilver( ihand ) ) { ahand[ nhand++ ] = Drop2Move(silver); }
21 if ( IsHandGold( ihand ) ) { ahand[ nhand++ ] = Drop2Move(gold); }
22 if ( IsHandBishop( ihand ) ) { ahand[ nhand++ ] = Drop2Move(bishop); }
23 if ( IsHandRook( ihand ) ) { ahand[ nhand++ ] = Drop2Move(rook); }
25 BBOr( bb_target, BB_BOCCUPY, BB_WOCCUPY );
26 BBNot( bb_target, bb_target );
27 ibb_target0a = bb_target.p[0] & 0x7fc0000U;
28 ibb_target0b = bb_target.p[0] & 0x003fe00U;
29 bb_target.p[0] &= 0x00001ffU;
30 bb_target.p[1] &= 0x7ffffffU;
31 bb_target.p[2] &= 0x7ffffffU;
33 if ( IsHandPawn( ihand ) )
35 ibb_pawn_cmp= BB_BPAWN_ATK.p[0] | BB_BPAWN_ATK.p[1] | BB_BPAWN_ATK.p[2];
36 ais_pawn[0] = ibb_pawn_cmp & ( mask_file1 >> 0 );
37 ais_pawn[1] = ibb_pawn_cmp & ( mask_file1 >> 1 );
38 ais_pawn[2] = ibb_pawn_cmp & ( mask_file1 >> 2 );
39 ais_pawn[3] = ibb_pawn_cmp & ( mask_file1 >> 3 );
40 ais_pawn[4] = ibb_pawn_cmp & ( mask_file1 >> 4 );
41 ais_pawn[5] = ibb_pawn_cmp & ( mask_file1 >> 5 );
42 ais_pawn[6] = ibb_pawn_cmp & ( mask_file1 >> 6 );
43 ais_pawn[7] = ibb_pawn_cmp & ( mask_file1 >> 7 );
44 ais_pawn[8] = ibb_pawn_cmp & ( mask_file1 >> 8 );
46 while ( BBToU( bb_target ) )
48 ito = LastOne( bb_target );
50 if ( ! ais_pawn[aifile[ito]] && ! IsMateBPawnDrop(__ptree__,ito) )
52 *pmove++ = utemp|Drop2Move(pawn);
54 for ( i = 0; i < nhand; i++ ) { *pmove++ = utemp | ahand[i]; }
55 Xor( ito, bb_target );
58 while ( ibb_target0b )
60 ito = last_one0( ibb_target0b );
62 if ( ! ais_pawn[aifile[ito]] && ! IsMateBPawnDrop(__ptree__,ito) )
64 *pmove++ = utemp | Drop2Move(pawn);
66 for ( i = noknight; i < nhand; i++ ) { *pmove++ = utemp|ahand[i]; }
67 ibb_target0b ^= abb_mask[ito].p[0];
71 while ( BBToU( bb_target ) )
73 ito = LastOne( bb_target );
75 for ( i = 0; i < nhand; i++ ) { *pmove++ = utemp|ahand[i]; }
76 Xor( ito, bb_target );
79 while ( ibb_target0b )
81 ito = last_one0( ibb_target0b );
83 for ( i = noknight; i < nhand; i++ ) { *pmove++ = utemp|ahand[ i ]; }
84 ibb_target0b ^= abb_mask[ ito ].p[0];
88 while ( ibb_target0a )
90 ito = last_one0( ibb_target0a );
92 for ( i = nolance; i < nhand; i++ ) { *pmove++ = utemp|ahand[ i ]; }
93 ibb_target0a ^= abb_mask[ ito ].p[0];
101 w_gen_drop( tree_t * restrict __ptree__, unsigned int * restrict pmove )
103 const tree_t * restrict ptree = __ptree__;
104 bitboard_t bb_target;
105 unsigned int ihand, ibb_target2a, ibb_target2b, ibb_pawn_cmp, utemp;
106 unsigned int ais_pawn[nfile];
107 int nhand, ito, i, nolance, noknight;
110 if ( ! HAND_W ) { return pmove; } /* return! */
113 if ( IsHandKnight( ihand ) ) { ahand[ nhand++ ] = Drop2Move(knight); }
115 if ( IsHandLance( ihand ) ) { ahand[ nhand++ ] = Drop2Move(lance); }
117 if ( IsHandSilver( ihand ) ) { ahand[ nhand++ ] = Drop2Move(silver); }
118 if ( IsHandGold( ihand ) ) { ahand[ nhand++ ] = Drop2Move(gold); }
119 if ( IsHandBishop( ihand ) ) { ahand[ nhand++ ] = Drop2Move(bishop); }
120 if ( IsHandRook( ihand ) ) { ahand[ nhand++ ] = Drop2Move(rook); }
122 BBOr( bb_target, BB_BOCCUPY, BB_WOCCUPY );
123 BBNot( bb_target, bb_target );
124 ibb_target2a = bb_target.p[2] & 0x00001ffU;
125 ibb_target2b = bb_target.p[2] & 0x003fe00U;
126 bb_target.p[0] &= 0x7ffffffU;
127 bb_target.p[1] &= 0x7ffffffU;
128 bb_target.p[2] &= 0x7fc0000U;
130 if ( IsHandPawn( ihand ) )
132 ibb_pawn_cmp= BB_WPAWN_ATK.p[0] | BB_WPAWN_ATK.p[1] | BB_WPAWN_ATK.p[2];
133 ais_pawn[0] = ibb_pawn_cmp & ( mask_file1 >> 0 );
134 ais_pawn[1] = ibb_pawn_cmp & ( mask_file1 >> 1 );
135 ais_pawn[2] = ibb_pawn_cmp & ( mask_file1 >> 2 );
136 ais_pawn[3] = ibb_pawn_cmp & ( mask_file1 >> 3 );
137 ais_pawn[4] = ibb_pawn_cmp & ( mask_file1 >> 4 );
138 ais_pawn[5] = ibb_pawn_cmp & ( mask_file1 >> 5 );
139 ais_pawn[6] = ibb_pawn_cmp & ( mask_file1 >> 6 );
140 ais_pawn[7] = ibb_pawn_cmp & ( mask_file1 >> 7 );
141 ais_pawn[8] = ibb_pawn_cmp & ( mask_file1 >> 8 );
143 while ( BBToU( bb_target ) )
145 ito = FirstOne( bb_target );
146 utemp = To2Move(ito);
147 if ( ! ais_pawn[aifile[ito]] && ! IsMateWPawnDrop(__ptree__,ito) )
149 *pmove++ = utemp | Drop2Move(pawn);
151 for ( i = 0; i < nhand; i++ ) { *pmove++ = utemp | ahand[i]; }
152 Xor( ito, bb_target );
155 while ( ibb_target2b )
157 ito = first_one2( ibb_target2b );
158 utemp = To2Move(ito);
159 if ( ! ais_pawn[aifile[ito]] && ! IsMateWPawnDrop(__ptree__,ito) )
161 *pmove++ = utemp | Drop2Move(pawn);
163 for ( i = noknight; i < nhand; i++ ) { *pmove++ = utemp | ahand[i]; }
164 ibb_target2b ^= abb_mask[ito].p[2];
168 while ( BBToU( bb_target ) )
170 ito = FirstOne( bb_target );
171 utemp = To2Move(ito);
172 for ( i = 0; i < nhand; i++ ) { *pmove++ = utemp|ahand[i]; }
173 Xor( ito, bb_target );
176 while ( ibb_target2b )
178 ito = first_one2( ibb_target2b );
179 utemp = To2Move(ito);
180 for ( i = noknight; i < nhand; i++ ) { *pmove++ = utemp|ahand[i]; }
181 ibb_target2b ^= abb_mask[ito].p[2];
185 while ( ibb_target2a )
187 ito = first_one2( ibb_target2a );
188 utemp = To2Move(ito);
189 for ( i = nolance; i < nhand; i++ ) { *pmove++ = utemp|ahand[i]; }
190 ibb_target2a ^= abb_mask[ito].p[2];