예제 #1
0
파일: magic.c 프로젝트: Die9teWoge/popeye
static void PushMagicView(square pos_viewed, square pos_magic, square start, square end)
{
  unsigned int const top = magic_views_top[stack_pointer];

  TraceFunctionEntry(__func__);
  TraceSquare(pos_viewed);
  TraceSquare(pos_magic);
  TraceSquare(start);
  TraceSquare(end);
  TraceFunctionParamListEnd();

  assert(magic_views_top[stack_pointer]<magicviews_size);

  magicviews[top].pos_viewed = pos_viewed;
  magicviews[top].viewedid = GetPieceId(being_solved.spec[pos_viewed]);
  magicviews[top].magicpieceid = GetPieceId(being_solved.spec[pos_magic]);
  magicviews[top].line_start = start;
  magicviews[top].line_end = end;
  ++magic_views_top[stack_pointer];

  TraceValue("%u",stack_pointer);
  TraceValue("%u\n",magic_views_top[stack_pointer]);

  TraceFunctionExit(__func__);
  TraceFunctionResultEnd();
}
예제 #2
0
파일: riders.c 프로젝트: Die9teWoge/popeye
boolean riders_check(vec_index_type kanf, vec_index_type kend,
                     validator_id evaluate)
{
  square const sq_target = move_generation_stack[CURRMOVE_OF_PLY(nbply)].capture;
  boolean result = false;

  TraceFunctionEntry(__func__);
  TraceSquare(sq_target);
  TraceFunctionParamListEnd();

  ++observation_context;

  TraceEnumerator(Side,trait[nbply],"\n");
  for (interceptable_observation[observation_context].vector_index1 = kanf;
       interceptable_observation[observation_context].vector_index1<= kend;
       ++interceptable_observation[observation_context].vector_index1)
  {
    square const sq_departure = find_end_of_line(sq_target,vec[interceptable_observation[observation_context].vector_index1]);
    TraceSquare(sq_departure);TraceEOL();
    if (EVALUATE_OBSERVATION(evaluate,sq_departure,sq_target))
    {
      result = true;
      break;
    }
  }

  --observation_context;

  TraceFunctionExit(__func__);
  TraceFunctionResult("%u",result);
  TraceFunctionResultEnd();
  return result;
}
예제 #3
0
static boolean are_all_imitator_arrivals_empty(square sq_departure, square sq_arrival)
{
  unsigned int imi_idx;
  int const diff = sq_arrival-sq_departure;
  boolean result = true;

  TraceFunctionEntry(__func__);
  TraceSquare(sq_departure);
  TraceSquare(sq_arrival);
  TraceFunctionParamListEnd();

  for (imi_idx = being_solved.number_of_imitators; imi_idx>0; imi_idx--)
  {
    square const j2 = being_solved.isquare[imi_idx-1]+diff;
    if (j2!=sq_departure && !is_square_empty(j2))
    {
      result = false;
      break;
    }
  }

  TraceFunctionExit(__func__);
  TraceFunctionResult("%u",result);
  TraceFunctionResultEnd();
  return result;
}
예제 #4
0
static void rider_placed(void)
{
  rider_placement_stack_elmt_type const * const save_top = stack_top;

  TraceFunctionEntry(__func__);
  TraceSquare(stack_top->placed_on);
  TraceFunctionParamListEnd();

  stack_top = stack_top->next;

  if (being_solved.king_square[White]==initsquare)
    (*save_top->go_on)();
  else
  {
    int const check_diff = being_solved.king_square[White]-save_top->placed_on;
    int const check_dir = CheckDir[get_walk_of_piece_on_square(save_top->placed_on)][check_diff];
    assert(check_dir!=check_diff);
    if (check_dir!=0
        && is_line_empty(save_top->placed_on,being_solved.king_square[White],check_dir))
      intelligent_intercept_check_by_black(check_dir,save_top->go_on);
    else
      (*save_top->go_on)();
  }

  assert(stack_top==save_top->next);
  stack_top = save_top;

  TraceFunctionExit(__func__);
  TraceFunctionResultEnd();
}
예제 #5
0
파일: pawn.c 프로젝트: thomas-maeder/popeye
unsigned int pawn_get_no_capture_length(Side side, square sq_departure)
{
  unsigned int result;
  SquareFlags const base_square = WhBaseSq+side;
  SquareFlags const doublestep_square = WhPawnDoublestepSq+side;

  TraceFunctionEntry(__func__);
  TraceEnumerator(Side,side);
  TraceSquare(sq_departure);
  TraceFunctionParamListEnd();

  if (TSTFLAG(sq_spec[sq_departure],base_square))
  {
    if (CondFlag[einstein])
      result = 3;
    else if (circe_variant.determine_rebirth_square==circe_determine_rebirth_square_equipollents
             || CondFlag[normalp]
             || circe_variant.determine_rebirth_square==circe_determine_rebirth_square_cage
             || get_walk_of_piece_on_square(sq_departure)==Orphan /* we are generating for a pawned Orphan! */
             || TSTFLAG(sq_spec[sq_departure],Wormhole))
      result = 1;
    else
      result = 0;
  }
  else if (TSTFLAG(sq_spec[sq_departure],doublestep_square))
    result = 2;
  else
    result = 1;

  TraceFunctionExit(__func__);
  TraceFunctionResult("%u",result);
  TraceFunctionResultEnd();
  return result;
}
예제 #6
0
/* Determine whether a specific piece delivers check to a specific side
 * @param observer_origin potentially delivering check ...
 * @note the piece on pos_checking must belong to advers(side)
 * @note sets observation_result
 */
void marscirce_is_square_observed(slice_index si)
{
  circe_rebirth_context_elmt_type * const context = &circe_rebirth_context_stack[circe_rebirth_context_stack_pointer-1];
  square const sq_target = move_generation_stack[CURRMOVE_OF_PLY(nbply)].capture;

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

  assert(circe_rebirth_context_stack_pointer>0);

  observation_result = false;

  if (observing_walk[nbply]<Queen || observing_walk[nbply]>Bishop
      || CheckDir[observing_walk[nbply]][sq_target-context->rebirth_square]!=0)
  {
    if (is_square_empty(context->rebirth_square))
    {
      TraceSquare(context->rebirth_square);
      TraceWalk(context->reborn_walk);
      TraceValue("%u",TSTFLAG(being_solved.spec[context->rebirth_square],White));
      TraceValue("%u",TSTFLAG(being_solved.spec[context->rebirth_square],Black));
      TraceEOL();
      occupy_square(context->rebirth_square,context->reborn_walk,context->reborn_spec);
      pipe_is_square_observed_delegate(si);
      empty_square(context->rebirth_square);
    }
  }

  TraceFunctionExit(__func__);
  TraceFunctionResultEnd();
}
예제 #7
0
static numecoup remove_illegal_moves_by_same_mao(numecoup curr, numecoup *new_top)
{
  square const sq_departure = move_generation_stack[curr].departure;

  TraceFunctionEntry(__func__);
  TraceValue("%u",curr);
  TraceSquare(sq_departure);
  TraceFunctionParamListEnd();

  while (curr<=CURRMOVE_OF_PLY(nbply)
         && move_generation_stack[curr].departure==sq_departure)
  {
    square const sq_arrival = move_generation_stack[curr].arrival;
    square const sq_hurdle = hoppper_moves_auxiliary[move_generation_stack[curr].id].sq_hurdle;

    if (are_all_imitator_arrivals_empty(sq_departure,sq_hurdle)
        && are_all_imitator_arrivals_empty(sq_departure,sq_arrival))
    {
      ++*new_top;
      move_generation_stack[*new_top] = move_generation_stack[curr];
    }

    ++curr;
  }

  TraceFunctionExit(__func__);
  TraceFunctionResult("%u",curr);
  TraceFunctionResultEnd();
  return curr;
}
예제 #8
0
void intelligent_place_pinned_black_piece(unsigned int placed_index,
                                          square placed_on,
                                          void (*go_on)(void))
{
  TraceFunctionEntry(__func__);
  TraceFunctionParam("%u",placed_index);
  TraceSquare(placed_on);
  TraceFunctionParamListEnd();

  switch (black[placed_index].type)
  {
    case Queen:
    case Rook:
    case Bishop:
      intelligent_place_pinned_black_rider(placed_index,placed_on,go_on);
      break;

    case Knight:
      intelligent_place_pinned_black_knight(placed_index,placed_on,go_on);
      break;

    case Pawn:
      intelligent_place_pinned_promoted_black_pawn(placed_index,placed_on,go_on);
      intelligent_place_pinned_unpromoted_black_pawn(placed_index,placed_on,go_on);
      break;

    default:
      assert(0);
      break;
  }

  TraceFunctionExit(__func__);
  TraceFunctionResultEnd();
}
예제 #9
0
void intelligent_place_black_rider(unsigned int placed_index,
                                   square placed_on,
                                   void (*go_on)(void))
{
  piece_walk_type const intercepter_type = black[placed_index].type;
  square const placed_comes_from = black[placed_index].diagram_square;
  int const check_diff = being_solved.king_square[White]-placed_on;
  int const check_dir = CheckDir[intercepter_type][check_diff];

  TraceFunctionEntry(__func__);
  TraceFunctionParam("%u",placed_index);
  TraceSquare(placed_on);
  TraceFunctionParamListEnd();

  if (check_dir!=check_diff
      && intelligent_reserve_officer_moves_from_to(Black,
                                                   placed_comes_from,
                                                   intercepter_type,
                                                   placed_on))
  {
    place_rider(placed_index,intercepter_type,placed_on,go_on);
    intelligent_unreserve();
  }

  TraceFunctionExit(__func__);
  TraceFunctionResultEnd();
}
예제 #10
0
void intelligent_place_pinned_promoted_black_knight(unsigned int placed_index,
                                                    square placed_on,
                                                    void (*go_on)(void))
{
  square const placed_comes_from = black[placed_index].diagram_square;
  Flags const placed_flags = black[placed_index].flags;

  TraceFunctionEntry(__func__);
  TraceFunctionParam("%u",placed_index);
  TraceSquare(placed_on);
  TraceFunctionParamListEnd();

  if ((being_solved.king_square[White]==initsquare
       || CheckDir[Knight][being_solved.king_square[White]-placed_on]==0)
      && intelligent_reserve_promoting_black_pawn_moves_from_to(placed_comes_from,
                                                                Knight,
                                                                placed_on))
  {
    occupy_square(placed_on,Knight,placed_flags);
    (*go_on)();
    intelligent_unreserve();
  }

  TraceFunctionExit(__func__);
  TraceFunctionResultEnd();
}
예제 #11
0
static void by_promoted_pawn(slice_index si,
                             unsigned int index_of_checker,
                             square const check_from)
{
  TraceFunctionEntry(__func__);
  TraceFunctionParam("%u",index_of_checker);
  TraceSquare(check_from);
  TraceFunctionParamListEnd();

  if (intelligent_can_promoted_white_pawn_theoretically_move_to(index_of_checker,
                                                                check_from))
  {
    piece_walk_type pp;
    for (pp = pieces_pawns_promotee_sequence[pieces_pawns_promotee_chain_orthodox][Empty]; pp!=Empty; pp = pieces_pawns_promotee_sequence[pieces_pawns_promotee_chain_orthodox][pp])
      switch (pp)
      {
        case Queen:
        case Rook:
        case Bishop:
          by_promoted_rider(si,index_of_checker,pp,check_from);
          break;

        case Knight:
          by_promoted_knight(si,index_of_checker,check_from);
          break;

        default:
          assert(0);
          break;
      }
  }

  TraceFunctionExit(__func__);
  TraceFunctionResultEnd();
}
예제 #12
0
static void init_disturb_mate_rider_onedir(square target, int dir, unsigned int index)
{
  square s;
  enum
  {
    nr_DisturbMateDirRider = sizeof DisturbMateDirRider / sizeof DisturbMateDirRider[0]
  };

  TraceFunctionEntry(__func__);
  TraceSquare(target);
  TraceFunctionParam("%d",dir);
  TraceFunctionParam("%u",index);
  TraceFunctionParamListEnd();

  assert(index<nr_DisturbMateDirRider);

  for (s = target+2*dir; is_square_empty(s); s += dir)
  {
    DisturbMateDirRider[index][s].dir = -dir;
    DisturbMateDirRider[index][s].target = target;
  }

  for (s = target-2*dir; is_square_empty(s); s -= dir)
  {
    DisturbMateDirRider[index][s].dir = dir;
    DisturbMateDirRider[index][s].target = target;
  }

  DisturbMateDirRider[index][target+dir].dir = disturbance_by_rider_uninterceptable;
  DisturbMateDirRider[index][target-dir].dir = disturbance_by_rider_uninterceptable;

  TraceFunctionExit(__func__);
  TraceFunctionResultEnd();
}
예제 #13
0
/* Is an en passant capture possible to a specific square?
 * @param side for which side
 * @param s the square
 * @return true iff an en passant capture to s is currently possible
 */
boolean en_passant_is_capture_possible_to(Side side, square s)
{
  boolean result = false;
  ply const ply_parent = parent_ply[nbply];

  TraceFunctionEntry(__func__);
  TraceEnumerator(Side,side);
  TraceSquare(s);
  TraceFunctionParamListEnd();

  TraceEnumerator(Side,trait[ply_parent]);
  TraceEOL();

  if (trait[ply_parent]!=side)
  {
    unsigned int i;

    for (i = en_passant_top[ply_parent-1]+1; i<=en_passant_top[ply_parent]; ++i)
      if (en_passant_multistep_over[i]==s)
      {
        result = true;
        break;
      }
  }

  TraceFunctionExit(__func__);
  TraceFunctionResult("%u",result);
  TraceFunctionResultEnd();
  return result;
}
예제 #14
0
/* Find a square for the opposite king
 * @param side side looking for a square for the opposite king
 */
static void advance_mate_square(Side side)
{
  Side const other_side = advers(side);

  TraceFunctionEntry(__func__);
  TraceEnumerator(Side,side,"");
  TraceFunctionParamListEnd();

  assert(republican_goal.type==goal_mate);

  being_solved.king_square[other_side] = king_placement[nbply]+1;
  ++being_solved.number_of_pieces[other_side][King];
  while (being_solved.king_square[other_side]<=square_h8)
    if (is_mate_square(other_side))
      break;
    else
      ++being_solved.king_square[other_side];

  --being_solved.number_of_pieces[other_side][King];
  king_placement[nbply] = being_solved.king_square[other_side];
  being_solved.king_square[other_side] = initsquare;

  TraceSquare(king_placement[nbply]);TraceEOL();

  TraceFunctionExit(__func__);
  TraceFunctionResultEnd();
}
예제 #15
0
static boolean is_mate_square(Side other_side)
{
  boolean result = false;

  if (is_square_empty(being_solved.king_square[other_side]))
  {
    TraceFunctionEntry(__func__);
    TraceEnumerator(Side,other_side,"");
    TraceFunctionParamListEnd();

    TraceSquare(being_solved.king_square[other_side]);TraceEOL();

    occupy_square(being_solved.king_square[other_side],King,BIT(Royal)|BIT(other_side));

    if (conditional_pipe_solve_delegate(temporary_hack_mate_tester[other_side])
        ==previous_move_has_solved)
      result = true;

    empty_square(being_solved.king_square[other_side]);

    TraceFunctionExit(__func__);
    TraceFunctionResult("%u",result);
    TraceFunctionResultEnd();
  }

  return result;
}
예제 #16
0
static void remember_killer_move()
{
  TraceFunctionEntry(__func__);
  TraceFunctionParamListEnd();

  killer_moves[nbply] = move_generation_stack[CURRMOVE_OF_PLY(nbply)];

  TraceValue("%u",nbply);
  TraceSquare(killer_moves[nbply].departure);
  TraceSquare(killer_moves[nbply].arrival);
  TraceSquare(killer_moves[nbply].capture);
  TraceEOL();

  TraceFunctionExit(__func__);
  TraceFunctionResultEnd();
}
예제 #17
0
파일: pawn.c 프로젝트: thomas-maeder/popeye
boolean pawn_check(validator_id evaluate)
{
  square const sq_target = move_generation_stack[CURRMOVE_OF_PLY(nbply)].capture;
  SquareFlags const capturable = trait[nbply]==White ? CapturableByWhPawnSq : CapturableByBlPawnSq;
  boolean result = false;

  TraceFunctionEntry(__func__);
  TraceFunctionParamListEnd();

  TraceSquare(sq_target);
  TraceEOL();

  if (TSTFLAG(sq_spec[sq_target],capturable) || observing_walk[nbply]==Orphan || observing_walk[nbply]>=Hunter0)
  {
    numvec const dir_forward = trait[nbply]==White ? dir_up : dir_down;
    numvec const dir_forward_right = dir_forward+dir_right;
    numvec const dir_forward_left = dir_forward+dir_left;

    if (pawn_test_check(sq_target-dir_forward_right,sq_target,evaluate))
      result = true;
    else if (pawn_test_check(sq_target-dir_forward_left,sq_target,evaluate))
      result = true;
    else if (en_passant_test_check(dir_forward_right,&pawn_test_check,evaluate))
      result = true;
    else if (en_passant_test_check(dir_forward_left,&pawn_test_check,evaluate))
      result = true;
  }

  TraceFunctionExit(__func__);
  TraceFunctionResult("%u",result);
  TraceFunctionResultEnd();
  return result;
}
예제 #18
0
static rider_disturbance_type how_does_rider_disturb(piece_walk_type placed_type,
                                                     square placed_on)
{
  rider_disturbance_type result = rider_doesnt_disturb;
  unsigned int const start = disturbance_by_rider_index_ranges[placed_type-Queen].start;
  unsigned int const end = disturbance_by_rider_index_ranges[placed_type-Queen].end;
  unsigned int i;

  TraceFunctionEntry(__func__);
  TraceWalk(placed_type);
  TraceSquare(placed_on);
  TraceFunctionParamListEnd();

  for (i = start; i<=end; ++i)
  {
    int const disturbance_dir = DisturbMateDirRider[i][placed_on].dir;
    if (disturbance_dir==disturbance_by_rider_uninterceptable)
    {
      result = rider_requires_pin;
      break;
    }
    else if (disturbance_dir!=0)
      result = rider_requires_interception;
  }

  TraceFunctionExit(__func__);
  TraceFunctionResult("%u",result);
  TraceFunctionResultEnd();
  return result;
}
예제 #19
0
void intelligent_place_promoted_black_rider(unsigned int placed_index,
                                            piece_walk_type promotee_type,
                                            square placed_on,
                                            void (*go_on)(void))
{
  square const placed_comes_from = black[placed_index].diagram_square;
  int const check_diff = being_solved.king_square[White]-placed_on;
  int const check_dir = CheckDir[promotee_type][check_diff];

  TraceFunctionEntry(__func__);
  TraceFunctionParam("%u",placed_index);
  TraceWalk(promotee_type);
  TraceSquare(placed_on);
  TraceFunctionParamListEnd();

  if (check_dir!=check_diff
      && intelligent_reserve_promoting_black_pawn_moves_from_to(placed_comes_from,
                                                                promotee_type,
                                                                placed_on))
  {
    place_rider(placed_index,promotee_type,placed_on,go_on);
    intelligent_unreserve();
  }

  TraceFunctionExit(__func__);
  TraceFunctionResultEnd();
}
예제 #20
0
static void by_unpromoted_pawn(slice_index si,
                               unsigned int index_of_checker,
                               square const check_from)
{
  square const checker_from = white[index_of_checker].diagram_square;
  Flags const checker_flags = white[index_of_checker].flags;
  SquareFlags const prom_square = BIT(WhPromSq)|BIT(BlPromSq);

  TraceFunctionEntry(__func__);
  TraceFunctionParam("%u",index_of_checker);
  TraceSquare(check_from);
  TraceFunctionParamListEnd();

  if (!TSTFLAGMASK(sq_spec[check_from],prom_square)
      && GuardDir[Pawn-Pawn][check_from].dir==guard_dir_check_uninterceptable
      && intelligent_reserve_white_pawn_moves_from_to_checking(checker_from,check_from))
  {
    occupy_square(check_from,Pawn,checker_flags);
    init_disturb_mate_dir(check_from,being_solved.king_square[Black]-check_from);
    pipe_solve_delegate(si);
    fini_disturb_mate_dir();
    empty_square(check_from);
    intelligent_unreserve();
  }

  TraceFunctionExit(__func__);
  TraceFunctionResultEnd();
}
예제 #21
0
void intelligent_place_pinned_unpromoted_black_pawn(unsigned int placed_index,
                                                    square placed_on,
                                                    void (*go_on)(void))
{
  Flags const placed_flags = black[placed_index].flags;
  square const placed_comes_from = black[placed_index].diagram_square;

  TraceFunctionEntry(__func__);
  TraceFunctionParam("%u",placed_index);
  TraceSquare(placed_on);
  TraceFunctionParamListEnd();

  if (!TSTFLAGMASK(sq_spec[placed_on],BIT(BlBaseSq)|BIT(BlPromSq))
      && !black_pawn_attacks_king(placed_on)
      && intelligent_reserve_black_pawn_moves_from_to_no_promotion(placed_comes_from,
                                                                   placed_on))
  {
    occupy_square(placed_on,Pawn,placed_flags);
    (*go_on)();
    intelligent_unreserve();
  }

  TraceFunctionExit(__func__);
  TraceFunctionResultEnd();
}
예제 #22
0
static void by_rider(slice_index si,
                     unsigned int index_of_checker,
                     square const check_from)
{
  piece_walk_type const checker_type = white[index_of_checker].type;
  Flags const checker_flags = white[index_of_checker].flags;
  int const diff = being_solved.king_square[Black]-check_from;
  int const dir = CheckDir[checker_type][diff];

  TraceFunctionEntry(__func__);
  TraceFunctionParam("%u",index_of_checker);
  TraceSquare(check_from);
  TraceFunctionParamListEnd();

  if (dir!=0
      && intelligent_reserve_white_officer_moves_from_to_checking(white[index_of_checker].diagram_square,
                                                                  checker_type,
                                                                  check_from))
  {
    occupy_square(check_from,checker_type,checker_flags);
    remember_mating_line(checker_type,check_from,+1);
    pipe_solve_delegate(si);
    remember_mating_line(checker_type,check_from,-1);
    intelligent_unreserve();
  }

  TraceFunctionExit(__func__);
  TraceFunctionResultEnd();
}
예제 #23
0
void intelligent_place_black_knight(unsigned int placed_index,
                                    square placed_on,
                                    void (*go_on)(void))
{
  Flags const placed_flags = black[placed_index].flags;
  square const placed_comes_from = black[placed_index].diagram_square;

  TraceFunctionEntry(__func__);
  TraceFunctionParam("%u",placed_index);
  TraceSquare(placed_on);
  TraceFunctionParamListEnd();

  if ((being_solved.king_square[White]==initsquare
       || CheckDir[Knight][being_solved.king_square[White]-placed_on]==0)
      && intelligent_reserve_officer_moves_from_to(Black,
                                                   placed_comes_from,
                                                   Knight,
                                                   placed_on))
  {
    occupy_square(placed_on,Knight,placed_flags);
    if (DisturbMateDirKnight[placed_on]==0)
      (*go_on)();
    else
      intelligent_pin_black_piece(placed_on,go_on);
    intelligent_unreserve();
  }

  TraceFunctionExit(__func__);
  TraceFunctionResultEnd();
}
예제 #24
0
static void by_knight(slice_index si,
                      unsigned int index_of_checker,
                      square const check_from)
{
  int const diff = being_solved.king_square[Black]-check_from;
  int const dir = CheckDir[Knight][diff];

  TraceFunctionEntry(__func__);
  TraceFunctionParam("%u",index_of_checker);
  TraceSquare(check_from);
  TraceFunctionParamListEnd();

  if (dir!=0
      && intelligent_reserve_white_officer_moves_from_to_checking(white[index_of_checker].diagram_square,
                                                                  Knight,
                                                                  check_from))
  {
    occupy_square(check_from,Knight,white[index_of_checker].flags);
    init_disturb_mate_dir(check_from,being_solved.king_square[Black]-check_from);
    pipe_solve_delegate(si);
    fini_disturb_mate_dir();
    intelligent_unreserve();
  }

  TraceFunctionExit(__func__);
  TraceFunctionResultEnd();
}
예제 #25
0
static boolean is_imitator_line_clear(unsigned int i,
                                      numvec diff_first_necessarily_empty,
                                      numvec step,
                                      numvec diff_first_not_necessarily_empty)
{
  boolean result = true;
  square const sq_first_not_necessarily_empty = being_solved.isquare[i]+diff_first_not_necessarily_empty;
  square sq_curr;

  TraceFunctionEntry(__func__);
  TraceValue("%u",i);
  TraceValue("%d",diff_first_necessarily_empty);
  TraceValue("%d",step);
  TraceValue("%d",diff_first_not_necessarily_empty);
  TraceFunctionParamListEnd();

  for (sq_curr = being_solved.isquare[i]+diff_first_necessarily_empty; sq_curr!=sq_first_not_necessarily_empty; sq_curr += step)
  {
    TraceSquare(sq_curr);TraceEOL();
    if (!is_square_empty(sq_curr))
    {
      result = false;
      break;
    }
  }

  TraceFunctionExit(__func__);
  TraceFunctionResult("%u",result);
  TraceFunctionResultEnd();
  return result;
}
예제 #26
0
/* Intercept with a white piece on some square
 * @param where_to_intercept where to intercept
 * @param go_on what to do after each successful interception?
 */
static void black_piece_on(boolean is_check, square where_to_intercept, void (*go_on)(void))
{
  unsigned int i;

  TraceFunctionEntry(__func__);
  TraceFunctionParam("%u",is_check);
  TraceSquare(where_to_intercept);
  TraceFunctionParamListEnd();

  for (i = 1; i<MaxPiece[Black]; ++i)
    if (black[i].usage==piece_is_unused)
    {
      black[i].usage = piece_intercepts;
      if (is_check)
        intelligent_place_pinned_black_piece(i,where_to_intercept,go_on);
      else
        intelligent_place_black_piece(i,where_to_intercept,go_on);
      black[i].usage = piece_is_unused;
    }

  empty_square(where_to_intercept);

  TraceFunctionExit(__func__);
  TraceFunctionResultEnd();
}
예제 #27
0
void intelligent_place_unpromoted_white_pawn(unsigned int placed_index,
                                             square placed_on,
                                             void (*go_on)(void))
{
  square const placed_comes_from = white[placed_index].diagram_square;
  Flags const placed_flags = white[placed_index].flags;

  TraceFunctionEntry(__func__);
  TraceFunctionParam("%u",placed_index);
  TraceSquare(placed_on);
  TraceFunctionParamListEnd();

  if (!TSTFLAGMASK(sq_spec[placed_on],BIT(WhBaseSq)|BIT(WhPromSq))
      && GuardDir[Pawn-Pawn][placed_on].dir<guard_dir_guard_uninterceptable
      && intelligent_reserve_white_pawn_moves_from_to_no_promotion(placed_comes_from,
                                                                   placed_on))
  {
    occupy_square(placed_on,Pawn,placed_flags);
    (*go_on)();
    intelligent_unreserve();
  }

  TraceFunctionExit(__func__);
  TraceFunctionResultEnd();
}
예제 #28
0
/* Place the white king; intercept checks if necessary
 * @param place_on where to place the king
 * @param go_on what to do after having placed the king?
 */
void intelligent_place_white_king(square place_on, void (*go_on)(void))
{
  TraceFunctionEntry(__func__);
  TraceSquare(place_on);
  TraceFunctionParamListEnd();

  if (!guards_from(place_on)
      && !is_square_uninterceptably_observed_ortho(Black,place_on)
      && intelligent_reserve_white_king_moves_from_to(white[index_of_king].diagram_square,
                                                      place_on))
  {
    being_solved.king_square[White] = place_on;
    occupy_square(place_on,King,white[index_of_king].flags);

    current_direction = vec_queen_start-1;
    go_on_after = go_on;
    continue_intercepting_checks();

    being_solved.king_square[White] = initsquare;
    empty_square(place_on);

    intelligent_unreserve();
  }

  TraceFunctionExit(__func__);
  TraceFunctionResultEnd();
}
예제 #29
0
static boolean advance_rebirth_square(void)
{
  boolean result = true;

  TraceFunctionEntry(__func__);
  TraceFunctionParamListEnd();

  do
  {
    if (circe_rebirth_context_stack[circe_rebirth_context_stack_pointer].rebirth_square<square_h8)
      ++circe_rebirth_context_stack[circe_rebirth_context_stack_pointer].rebirth_square;
    else
    {
      circe_rebirth_context_stack[circe_rebirth_context_stack_pointer].rebirth_square = initsquare;
      result = false;
      break;
    }
  } while (is_square_blocked(circe_rebirth_context_stack[circe_rebirth_context_stack_pointer].rebirth_square));

  TraceSquare(circe_rebirth_context_stack[circe_rebirth_context_stack_pointer].rebirth_square);
  TraceEOL();

  TraceFunctionExit(__func__);
  TraceFunctionResult("%u",result);
  TraceFunctionResultEnd();
  return result;
}
예제 #30
0
void intelligent_place_promoted_white_knight(unsigned int placed_index,
                                             square placed_on,
                                             void (*go_on)(void))
{
  square const placed_comes_from = white[placed_index].diagram_square;
  Flags const placed_flags = white[placed_index].flags;

  TraceFunctionEntry(__func__);
  TraceFunctionParam("%u",placed_index);
  TraceSquare(placed_on);
  TraceFunctionParamListEnd();

  if (GuardDir[Knight-Pawn][placed_on].dir<guard_dir_guard_uninterceptable
      && intelligent_reserve_promoting_white_pawn_moves_from_to(placed_comes_from,
                                                                Knight,
                                                                placed_on))
  {
    occupy_square(placed_on,Knight,placed_flags);
    (*go_on)();
    intelligent_unreserve();
  }

  TraceFunctionExit(__func__);
  TraceFunctionResultEnd();
}