/* Intercept a check to the white king with a black piece
 * @param dir_from_rider direction from rider giving check to white king
 * @param go_on what to do after each successful interception?
 */
static void black_piece(slice_index si,
                        int dir_to_rider,
                        void (*go_on)(slice_index si))
{
  square const start = being_solved.king_square[White]-dir_to_rider;
  boolean const is_diagonal = SquareCol(being_solved.king_square[White])==SquareCol(start);
  square where_to_intercept;

  TraceFunctionEntry(__func__);
  TraceFunctionParam("%d",dir_to_rider);
  TraceFunctionParamListEnd();

  for (where_to_intercept = start;
       is_square_empty(where_to_intercept);
       where_to_intercept -= dir_to_rider)
    if (nr_reasons_for_staying_empty[where_to_intercept]==0
        && *where_to_start_placing_black_pieces<=where_to_intercept)
      black_piece_on(si,where_to_intercept,is_diagonal,go_on);

  TraceFunctionExit(__func__);
  TraceFunctionResultEnd();
}
示例#2
0
/* Intercept with a black piece
 * @param guard of what square
 * @param dir_from_rider direction from rider giving check to black king
 * @param go_on what to do after each successful interception?
 */
static void black_piece(square target, int dir_from_rider, void (*go_on)(void))
{
  Flags const mask = BIT(Black)|BIT(Royal);
  boolean const is_check = TSTFULLFLAGMASK(being_solved.spec[target+dir_from_rider],mask);
  square where_to_intercept;

  TraceFunctionEntry(__func__);
  TraceSquare(target);
  TraceFunctionParam("%d",dir_from_rider);
  TraceFunctionParamListEnd();

  for (where_to_intercept = target-dir_from_rider;
       is_square_empty(where_to_intercept);
       where_to_intercept -= dir_from_rider)
    if (nr_reasons_for_staying_empty[where_to_intercept]==0
      /* avoid testing the same position twice */
        && *where_to_start_placing_black_pieces<=where_to_intercept)
      black_piece_on(is_check,where_to_intercept,go_on);

  TraceFunctionExit(__func__);
  TraceFunctionResultEnd();
}