/* Try to solve in solve_nr_remaining half-moves. * @param si slice index * @note assigns solve_result the length of solution found and written, i.e.: * previous_move_is_illegal the move just played is illegal * this_move_is_illegal the move being played is illegal * immobility_on_next_move the moves just played led to an * unintended immobility on the next move * <=n+1 length of shortest solution found (n+1 only if in next * branch) * n+2 no solution found in this branch * n+3 no solution found in next branch * (with n denominating solve_nr_remaining) */ void imitator_pawn_promoter_solve(slice_index si) { TraceFunctionEntry(__func__); TraceFunctionParam("%u",si); TraceFunctionParamListEnd(); { square sq_arrival; Side as_side; find_potential_promotion_square(promotion_horizon[nbply],&sq_arrival,&as_side); assert(stack_pointer<stack_size); if (post_move_iteration_id[nbply]!=prev_post_move_iteration_id[stack_pointer]) promotion_into_imitator[stack_pointer] = is_square_occupied_by_promotable_pawn(sq_arrival,as_side); TraceValue("%u",post_move_iteration_id[nbply]); TraceValue("%u",prev_post_move_iteration_id[stack_pointer]); TraceValue("%u\n",promotion_into_imitator[stack_pointer]); if (promotion_into_imitator[stack_pointer]) { move_effect_journal_index_type const save_horizon = promotion_horizon[nbply]; promotion_horizon[nbply] = move_effect_journal_base[nbply+1]; move_effect_journal_do_piece_removal(move_effect_reason_pawn_promotion, sq_arrival); move_effect_journal_do_imitator_addition(move_effect_reason_pawn_promotion, sq_arrival); ++stack_pointer; fork_solve_delegate(si); --stack_pointer; promotion_horizon[nbply] = save_horizon; TraceValue("%u\n",post_move_iteration_locked[nbply]); if (!post_move_iteration_locked[nbply]) { promotion_into_imitator[stack_pointer] = false; lock_post_move_iterations(); } } else { ++stack_pointer; pipe_solve_delegate(si); --stack_pointer; } prev_post_move_iteration_id[stack_pointer] = post_move_iteration_id[nbply]; } TraceFunctionExit(__func__); TraceFunctionResultEnd(); }
/* Try to solve in solve_nr_remaining half-moves. * @param si slice index * @note assigns solve_result the length of solution found and written, i.e.: * previous_move_is_illegal the move just played is illegal * this_move_is_illegal the move being played is illegal * immobility_on_next_move the moves just played led to an * unintended immobility on the next move * <=n+1 length of shortest solution found (n+1 only if in next * branch) * n+2 no solution found in this branch * n+3 no solution found in next branch * (with n denominating solve_nr_remaining) */ void nopromotion_avoid_promotion_moving_solve(slice_index si) { TraceFunctionEntry(__func__); TraceFunctionParam("%u",si); TraceFunctionParamListEnd(); { move_effect_journal_index_type const base = move_effect_journal_base[nbply]; move_effect_journal_index_type const movement = base+move_effect_journal_index_offset_movement; square const sq_arrival = move_effect_journal[movement].u.piece_movement.to; PieceIdType const moving_id = GetPieceId(move_effect_journal[movement].u.piece_movement.movingspec); square const pos = move_effect_journal_follow_piece_through_other_effects(nbply, moving_id, sq_arrival); pipe_this_move_illegal_if(si,is_square_occupied_by_promotable_pawn(pos,trait[nbply])); } TraceFunctionExit(__func__); TraceFunctionResultEnd(); }