@@ -234,42 +234,60 @@ int search(GAME *game, UINT incheck, int alpha, int beta, int depth, MOVE exclud
234234 }
235235
236236 // Pruning or depth reductions
237- if (! root_node && !extensions && move_count > 1 && move_is_quiet ( move ) ) {
237+ if ( !extensions && move_count > 1 ) {
238238 if (!is_killer_move (& game -> move_order , turn , ply , move )) {
239239 if (!is_counter_move (& game -> move_order , flip_color (turn ), get_last_move_made (& game -> board ), move )) {
240240 int move_has_bad_history = get_has_bad_history (& game -> move_order , turn , move );
241241 // Move count pruning: prune moves based on move count.
242- if (!pv_node && move_has_bad_history && depth < 8 && !incheck ) {
242+ if (!root_node && ! pv_node && move_has_bad_history && depth < 8 && !incheck && move_is_quiet ( move ) ) {
243243 int pruning_threshold = 4 + depth * 2 ;
244244 if (!improving ) pruning_threshold = pruning_threshold - 3 ;
245- if (move_count > pruning_threshold ) continue ;
245+ if (move_count > pruning_threshold ) {
246+ continue ;
247+ }
246248 }
247249 // Futility pruning: eval + margin below beta. Uses beta cutoff history.
248- if (depth < 8 && (!pv_node || !incheck ) && !is_mate_score (alpha )) {
250+ if (! root_node && depth < 8 && (!pv_node || !incheck ) && !is_mate_score (alpha ) && move_is_quiet ( move )) {
249251 int pruning_margin = depth * (50 + get_pruning_margin (& game -> move_order , turn , move ));
250252 if (eval_score + pruning_margin < alpha ) {
251253 continue ;
252254 }
253255 }
254- // Late move reductions: reduce depth for later moves
255- reductions += reduction_table [MIN (depth , MAX_DEPTH - 1 )][MIN (move_count , MAX_MOVE - 1 )];
256- if (!pv_node ) {
257- if (move_has_bad_history || !improving || (incheck && unpack_piece (move ) == KING )) reductions ++ ;
258- if (trans_move != MOVE_NONE && !move_is_quiet (trans_move )) reductions ++ ;
256+ // Pruning based on SEE heuristic.
257+ if (!root_node && depth <= 8 && !incheck ) {
258+ int see_margin = 0 ;
259+ if (move_is_quiet (move )) {
260+ see_margin = -60 * depth ;
261+ }
262+ else {
263+ see_margin = -10 * depth * depth ;
264+ }
265+ if (see_move (& game -> board , move ) < see_margin ) {
266+ continue ;
267+ }
259268 }
260- else {
261- if (reductions > 0 && !move_has_bad_history ) reductions -- ;
262- if (reductions > 0 && incheck ) reductions -- ;
269+ // Late move reductions: reduce depth for later moves
270+ if (move_is_quiet (move )) {
271+ reductions += reduction_table [MIN (depth , MAX_DEPTH - 1 )][MIN (move_count , MAX_MOVE - 1 )];
272+ if (!pv_node ) {
273+ if (move_has_bad_history || !improving || (incheck && unpack_piece (move ) == KING )) reductions ++ ;
274+ if (trans_move != MOVE_NONE && !move_is_quiet (trans_move )) reductions ++ ;
275+ }
276+ else {
277+ if (reductions > 0 && !move_has_bad_history ) reductions -- ;
278+ if (reductions > 0 && incheck ) reductions -- ;
279+ if (reductions > 0 && root_node ) reductions -- ;
280+ }
263281 }
264282 }
265283 }
266284 }
267285
268- if (!root_node && move_count > 5 && !extensions && !incheck && depth < 5 && !move_is_quiet (move )) {
269- if (best_score + 100 * depth + see_move (& game -> board , move ) <= alpha ) {
270- continue ;
271- }
272- }
286+ // if (!root_node && move_count > 5 && !extensions && !incheck && depth < 5 && !move_is_quiet(move)) {
287+ // if (best_score + 100 * depth + see_move(&game->board, move) <= alpha) {
288+ // continue;
289+ // }
290+ // }
273291
274292 // Make move and search new position.
275293 make_move (& game -> board , move );
0 commit comments