예제 #1
0
파일: annan.c 프로젝트: Die9teWoge/popeye
static boolean annanises(Side side, square rear, square front)
{
  boolean result = false;

  TraceFunctionEntry(__func__);
  TraceEnumerator(Side,side,"");
  TraceSquare(rear);
  TraceSquare(front);
  TraceFunctionParamListEnd();

  if (TSTFLAG(being_solved.spec[rear],side))
  {
    Flags const mask = BIT(side)|BIT(Royal);

    switch(annan_type)
    {
      case ConditionTypeA:
        result = true;
        break;

      case ConditionTypeB:
        result = !TSTFULLFLAGMASK(being_solved.spec[rear],mask);
        break;

      case ConditionTypeC:
        result = !TSTFULLFLAGMASK(being_solved.spec[front],mask);
        break;

      case ConditionTypeD:
        result = !TSTFULLFLAGMASK(being_solved.spec[rear],mask) && !TSTFULLFLAGMASK(being_solved.spec[front],mask);
        break;

      default:
        assert(0);
        break;
    }
  }

  TraceFunctionExit(__func__);
  TraceFunctionResult("%u",result);
  TraceFunctionResultEnd();
  return result;
}
예제 #2
0
static void init_disturb_mate_dir_rider(square const check_from, int dir)
{
  vec_index_type i;
  unsigned int disturb_index = 0;
  Flags const mask = BIT(Black)|BIT(Royal);

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

  disturbance_by_rider_index_ranges[Queen-Queen].start = disturb_index;
  disturbance_by_rider_index_ranges[Rook-Queen].start = disturb_index;
  for (i = vec_rook_start; i<=vec_rook_end; ++i)
    if (vec[i]>0)
    {
      square s;
      for (s = check_from; !TSTFULLFLAGMASK(being_solved.spec[s],mask); s += dir)
        init_disturb_mate_rider_onedir(s,vec[i],disturb_index);
      ++disturb_index;
    }
  disturbance_by_rider_index_ranges[Rook-Queen].end = disturb_index-1;

  disturbance_by_rider_index_ranges[Bishop-Queen].start = disturb_index;
  for (i = vec_bishop_start; i<=vec_bishop_end; ++i)
    if (vec[i]>0)
    {
      square s;
      for (s = check_from; !TSTFULLFLAGMASK(being_solved.spec[s],mask); s += dir)
        init_disturb_mate_rider_onedir(s,vec[i],disturb_index);
      ++disturb_index;
    }
  disturbance_by_rider_index_ranges[Bishop-Queen].end = disturb_index-1;
  disturbance_by_rider_index_ranges[Queen-Queen].end = disturb_index-1;

  TraceFunctionExit(__func__);
  TraceFunctionResultEnd();
}
예제 #3
0
/* Generate moves for a single piece
 * @param identifies generator slice
 */
void vaulting_kings_generate_moves_for_piece(slice_index si)
{
  Side const side = trait[nbply];
  Flags const mask = BIT(side)|BIT(Royal);

  if (TSTFULLFLAGMASK(being_solved.spec[curr_generation->departure],mask))
  {
    if (is_kingsquare_observed())
    {
      unsigned int i;
      for (i = 0; i!=nr_king_vaulters[side]; ++i)
        pipe_move_generation_differnt_walk_delegate(si,king_vaulters[side][i]);
    }
    else if (vaulting_kings_transmuting[side])
      return; /* don't generate non-vaulting moves */
  }

  pipe_solve_delegate(si);
}
예제 #4
0
/* Generate moves for a single piece
 * @param identifies generator slice
 */
void transmuting_kings_generate_moves_for_piece(slice_index si)
{
  Flags const mask = BIT(trait[nbply])|BIT(Royal);

  TraceFunctionEntry(__func__);
  TraceFunctionParam("%u",si);
  TraceFunctionParamListEnd();

  if (TSTFULLFLAGMASK(being_solved.spec[curr_generation->departure],mask))
  {
    if (!generate_moves_of_transmuting_king(si))
      pipe_move_generation_delegate(si);
  }
  else
    pipe_move_generation_delegate(si);

  TraceFunctionExit(__func__);
  TraceFunctionResultEnd();
}
예제 #5
0
static void init_disturb_mate_dir_knight(square const check_from, int dir)
{
  square s;
  Flags const mask = BIT(Black)|BIT(Royal);

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

  for (s = check_from; !TSTFULLFLAGMASK(being_solved.spec[s],mask); s += dir)
  {
    vec_index_type i;
    for (i = vec_knight_start; i<=vec_knight_end; ++i)
      DisturbMateDirKnight[s+vec[i]] = vec[i];
  }

  TraceFunctionExit(__func__);
  TraceFunctionResultEnd();
}
예제 #6
0
파일: central.c 프로젝트: Die9teWoge/popeye
static boolean is_mover_supported_recursive(void)
{
  boolean result;
  Flags const mask = BIT(trait[nbply])|BIT(Royal);

  TraceFunctionEntry(__func__);
  TraceFunctionParamListEnd();

  TraceSquare(move_generation_stack[CURRMOVE_OF_PLY(nbply)].capture);
  TraceEOL();

  if (TSTFULLFLAGMASK(being_solved.spec[move_generation_stack[CURRMOVE_OF_PLY(nbply)].capture],mask))
    result = true;
  else
    result = is_square_observed(EVALUATE(observation));

  TraceFunctionExit(__func__);
  TraceFunctionResult("%u",result);
  TraceFunctionResultEnd();
  return result;
}
예제 #7
0
/* 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 circe_assassin_assassinate_solve(slice_index si)
{
  circe_rebirth_context_elmt_type const * const context = &circe_rebirth_context_stack[circe_rebirth_context_stack_pointer];
  square const sq_rebirth = context->rebirth_square;
  Flags const mask = BIT(SLICE_STARTER(si))|BIT(Royal);

  TraceFunctionEntry(__func__);
  TraceFunctionParam("%u",si);
  TraceFunctionParamListEnd();

  if (TSTFULLFLAGMASK(being_solved.spec[sq_rebirth],mask))
    solve_result = this_move_is_illegal;
  else
  {
    move_effect_journal_do_piece_removal(move_effect_reason_assassin_circe_rebirth,
                                         sq_rebirth);
    pipe_dispatch_delegate(si);
  }

  TraceFunctionExit(__func__);
  TraceFunctionResultEnd();
}
예제 #8
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();
}
예제 #9
0
static void init_disturb_mate_dir_pawn(square const check_from, int dir)
{
  square s;
  Flags const mask = BIT(Black)|BIT(Royal);

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

  for (s = check_from+dir; !TSTFULLFLAGMASK(being_solved.spec[s],mask); s += dir)
  {
    DisturbMateDirPawn[s+dir_up] = disturbance_by_pawn_interception_single;
    if (square_a5<=s && s<=square_h5)
      DisturbMateDirPawn[s+2*dir_up] = disturbance_by_pawn_interception_double;
  }

  /* only now - capture trumps interception */
  DisturbMateDirPawn[check_from+dir_up+dir_left] = disturbance_by_pawn_capture;
  DisturbMateDirPawn[check_from+dir_up+dir_right] = disturbance_by_pawn_capture;

  TraceFunctionExit(__func__);
  TraceFunctionResultEnd();
}