Ejemplo n.º 1
0
static void keepmating_filter_inserter_battle(slice_index si,
                                              stip_structure_traversal *st)
{
  TraceFunctionEntry(__func__);
  TraceFunctionParam("%u",si);
  TraceFunctionParamListEnd();

  stip_traverse_structure_children_pipe(si,st);

  if (st->context!=stip_traversal_context_help)
  {
    insertion_state_type const * const state = st->param;
    slice_index const prototype = alloc_appropriate_filter(state);
    if (prototype!=no_slice)
    {
      SLICE_STARTER(prototype) = SLICE_STARTER(si);
      if (st->context==stip_traversal_context_attack)
        attack_branch_insert_slices(si,&prototype,1);
      else
        defense_branch_insert_slices(si,&prototype,1);
    }
  }

  TraceFunctionExit(__func__);
  TraceFunctionResultEnd();
}
Ejemplo n.º 2
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 goalreachable_guard_mate_solve(slice_index si)
{
  Side const just_moved = advers(SLICE_STARTER(si));

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

  --MovesLeft[just_moved];
  TraceEnumerator(Side,SLICE_STARTER(si));
  TraceEnumerator(Side,just_moved);
  TraceValue("%u",MovesLeft[SLICE_STARTER(si)]);
  TraceValue("%u",MovesLeft[just_moved]);
  TraceEOL();

  pipe_this_move_doesnt_solve_if(si,!mate_isGoalReachable());

  ++MovesLeft[just_moved];
  TraceValue("%u",MovesLeft[SLICE_STARTER(si)]);
  TraceValue("%u",MovesLeft[just_moved]);
  TraceEOL();

  TraceFunctionExit(__func__);
  TraceFunctionResultEnd();
}
Ejemplo n.º 3
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 singlebox_type2_latent_pawn_selector_solve(slice_index si)
{
  TraceFunctionEntry(__func__);
  TraceFunctionParam("%u",si);
  TraceFunctionParamListEnd();

  if (post_move_iteration_id[nbply]!=prev_post_move_iteration_id_selection[nbply])
    init_latent_pawn_selection(SLICE_STARTER(si));

  pipe_solve_delegate(si);

  if (singlebox_type2_latent_pawn_promotions[nbply].where!=initsquare)
  {
    if (!post_move_iteration_locked[nbply])
    {
      advance_latent_pawn_selection(SLICE_STARTER(si));

      if (singlebox_type2_latent_pawn_promotions[nbply].where!=initsquare)
        lock_post_move_iterations();
    }
  }

  prev_post_move_iteration_id_selection[nbply] = post_move_iteration_id[nbply];

  TraceFunctionExit(__func__);
  TraceFunctionResultEnd();
}
Ejemplo n.º 4
0
/* Impose the starting side on a stipulation.
 * @param si identifies slice
 * @param st address of structure that holds the state of the traversal
 */
void impose_starter_goal_immobile_tester(slice_index si,
                                         stip_structure_traversal *st)
{
  Side * const starter = st->param;

  TraceFunctionEntry(__func__);
  TraceFunctionParam("%u",si);
  TraceEnumerator(Side,*starter,"");
  TraceFunctionParamListEnd();

  SLICE_STARTER(si) = *starter;
  stip_traverse_structure_children_pipe(si,st);

  {
    Side const immobilised = (SLICE_U(si).goal_filter.applies_to_who
                              ==goal_applies_to_starter
                              ? SLICE_STARTER(si)
                              : advers(SLICE_STARTER(si)));
    *starter = immobilised;
    stip_traverse_structure_conditional_pipe_tester(si,st);
  }

  *starter = SLICE_STARTER(si);

  TraceFunctionExit(__func__);
  TraceFunctionResultEnd();
}
Ejemplo n.º 5
0
static char *ParseReciGoal(char *tok,
                           slice_index start,
                           slice_index proxy_nonreci,
                           slice_index proxy_reci)
{
    char *result = 0;

    TraceFunctionEntry(__func__);
    TraceFunctionParam("%s",tok);
    TraceFunctionParamListEnd();

    if (*tok=='(')
    {
        char const *closingParenPos = strchr(tok,')');
        if (closingParenPos!=0)
        {
            slice_index const proxy_to_reci = alloc_proxy_slice();
            tok = ParseGoal(tok+1,start,proxy_to_reci);
            if (tok!=0)
            {
                if (tok==closingParenPos)
                {
                    slice_index const proxy_to_nonreci = alloc_proxy_slice();
                    result = ParseGoal(tok+1,start,proxy_to_nonreci);
                    if (result!=NULL)
                    {
                        slice_index const nonreci = SLICE_NEXT1(proxy_to_nonreci);
                        SLICE_STARTER(nonreci) = Black;
                        alloc_reci_end(proxy_nonreci,proxy_reci,
                                       proxy_to_nonreci,proxy_to_reci);
                    }
                }
                else
                    output_plaintext_input_error_message(UnrecStip, 0);
            }
        }
        else
            output_plaintext_input_error_message(UnrecStip, 0);
    }
    else
    {
        slice_index const proxy_to_nonreci = alloc_proxy_slice();
        result = ParseGoal(tok,start,proxy_to_nonreci);
        if (result!=NULL)
        {
            slice_index const nonreci_testing = SLICE_NEXT1(proxy_to_nonreci);
            slice_index const nonreci_tester = SLICE_NEXT1(nonreci_testing);
            slice_index const proxy_to_reci = stip_deep_copy(proxy_to_nonreci);
            alloc_reci_end(proxy_nonreci,proxy_reci,
                           proxy_to_nonreci,proxy_to_reci);
            SLICE_STARTER(nonreci_tester) = Black;
        }
    }

    TraceFunctionExit(__func__);
    TraceFunctionResult("%s",result);
    TraceFunctionResultEnd();
    return result;
}
static void substitute_king_first(slice_index si, stip_structure_traversal *st)
{
  TraceFunctionEntry(__func__);
  TraceFunctionParam("%u",si);
  TraceFunctionParamListEnd();

  assert(SLICE_STARTER(si)!=no_side);

  stip_traverse_structure_children_pipe(si,st);

  /* this optimisation doesn't work if an ultra-mummer condition applies
   * to the side to be immobilised */
  if (mummer_strictness[SLICE_STARTER(si)]<=mummer_strictness_regular)
  {
    slice_index const proxy1 = alloc_proxy_slice();
    slice_index const proxy2 = alloc_proxy_slice();
    slice_index const king_branch = SLICE_NEXT1(si);
    slice_index const nonking_branch = stip_deep_copy(king_branch);
    slice_index const king_move_tester = alloc_pipe(STImmobilityTester);
    slice_index const nonking_move_tester = alloc_pipe(STImmobilityTester);

    pipe_link(si,alloc_and_slice(proxy1,proxy2));

    pipe_link(proxy1,king_move_tester);
    link_to_branch(king_move_tester,king_branch);

    {
      slice_index const generator = branch_find_slice(STMoveGenerator,
                                                      king_branch,
                                                      stip_traversal_context_intro);
      assert(generator!=no_slice);
      pipe_substitute(generator,alloc_king_move_generator_slice());
    }

    pipe_link(proxy2,nonking_move_tester);
    link_to_branch(nonking_move_tester,nonking_branch);

    {
      slice_index const generator = branch_find_slice(STMoveGenerator,
                                                      nonking_branch,
                                                      stip_traversal_context_intro);
      assert(generator!=no_slice);
      pipe_substitute(generator,alloc_non_king_move_generator_slice());
    }

    pipe_remove(si);
  }

  TraceFunctionExit(__func__);
  TraceFunctionResultEnd();
}
Ejemplo n.º 7
0
/* Instrument the solvers with Patrol Chess
 * @param si identifies the root slice of the stipulation
 */
void solving_insert_nocapture(slice_index si)
{
  stip_structure_traversal st;
  boolean enabled[nr_sides] =
  {
      CondFlag[nocapture] || CondFlag[nowhcapture],
      CondFlag[nocapture] || CondFlag[noblcapture]
  };

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

  TraceStipulation(si);

  solving_impose_starter(si,SLICE_STARTER(si));

  stip_structure_traversal_init(&st,&enabled);
  stip_structure_traversal_override_single(&st,
                                           STDoneGeneratingMoves,
                                           &insert_remover);
  stip_traverse_structure(si,&st);

  TraceFunctionExit(__func__);
  TraceFunctionResultEnd();
}
Ejemplo n.º 8
0
static void instrument_move(slice_index si, stip_structure_traversal *st)
{
  TraceFunctionEntry(__func__);
  TraceFunctionParam("%u",si);
  TraceFunctionParamListEnd();

  if (SLICE_STARTER(si)==Black)
  {
    slice_index * const landing = st->param;
    slice_index const save_landing = *landing;

    *landing = no_slice;
    insert_landing(si,st);

    stip_traverse_structure_children(si,st);

    insert_null_move_handler(si,st);
    *landing = save_landing;

    {
      slice_index const prototype = alloc_pipe(STBlackChecks);
      move_insert_slices(si,st->context,&prototype,1);
    }
  }
  else
    stip_traverse_structure_children(si,st);

  TraceFunctionExit(__func__);
  TraceFunctionResultEnd();
}
Ejemplo n.º 9
0
char *ParseStip(char *tok, slice_index start)
{
    slice_index const root_slice_hook = alloc_proxy_slice();

    TraceFunctionEntry(__func__);
    TraceFunctionParam("%s",tok);
    TraceFunctionParam("%u",start);
    TraceFunctionParamListEnd();

    stipulation_reset();

    if (ParsePlay(tok,start,root_slice_hook,play_length_minimum))
    {
        move_effect_journal_do_insert_stipulation(start,root_slice_hook);
        tok = ReadNextTokStr();
    }
    else
        dealloc_slices(root_slice_hook);

    /* signal to our caller that the stipulation has changed */
    SLICE_STARTER(root_slice_hook) = no_side;

    TraceFunctionExit(__func__);
    TraceFunctionResult("%s",tok);
    TraceFunctionResultEnd();
    return tok;
}
Ejemplo n.º 10
0
/* Parse a structured stipulation (keyword sstipulation)
 * @param start index of entry into solving machinery
 * @return remainder of input token; 0 if parsing failed
 */
char *ParseStructuredStip(char *tok, slice_index start)
{
  slice_index const root_slice_hook = alloc_proxy_slice();
  Side starter;

  TraceFunctionEntry(__func__);
  TraceFunctionParam("%s",tok);
  TraceFunctionParam("%u",root_slice_hook);
  TraceFunctionParamListEnd();

  stipulation_reset();

  starter = ParseStructuredStip_starter(tok);
  if (starter!=no_side)
  {
    expression_type type;
    tok = ReadNextTokStr();
    tok = ParseStructuredStip_expression(tok,start,root_slice_hook,&type,0);
    if (tok==0)
      tok = ReadNextTokStr();
    else if (SLICE_NEXT1(root_slice_hook)!=no_slice)
    {
      solving_impose_starter(root_slice_hook,starter);
      move_effect_journal_do_insert_sstipulation(start,root_slice_hook);
    }
  }

  /* signal to our caller that the stipulation has changed */
  SLICE_STARTER(root_slice_hook) = no_side;

  TraceFunctionExit(__func__);
  TraceFunctionResult("%s",tok);
  TraceFunctionResultEnd();
  return tok;
}
Ejemplo n.º 11
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 orthodox_mating_king_contact_generator_solve(slice_index si)
{
  Side const moving = SLICE_STARTER(si);
  Side const mated = advers(moving);
  square const sq_mated_king = being_solved.king_square[mated];

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

  assert(solve_nr_remaining==slack_length+1);

  curr_generation->departure = being_solved.king_square[moving];

  if (curr_generation->departure!=sq_mated_king)
  {
    vec_index_type k;
    for (k = vec_queen_start; k<=vec_queen_end; k++)
    {
      curr_generation->arrival = curr_generation->departure+vec[k];
      if ((is_square_empty(curr_generation->arrival)
          || TSTFLAG(being_solved.spec[curr_generation->arrival],mated))
          && move_diff_code[abs(sq_mated_king-curr_generation->arrival)]<=1+1)
        push_move();
    }
  }

  pipe_solve_delegate(si);

  TraceFunctionExit(__func__);
  TraceFunctionResultEnd();
}
Ejemplo n.º 12
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 half_neutral_recolorer_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;
    Flags const movingspec = move_effect_journal[movement].u.piece_movement.movingspec;
    PieceIdType const moving_id = GetPieceId(movingspec);
    square const pos = move_effect_journal_follow_piece_through_other_effects(nbply,
                                                                              moving_id,
                                                                              sq_arrival);

    if (TSTFLAG(movingspec,HalfNeutral))
    {
      if (is_piece_neutral(being_solved.spec[pos]))
        do_deneutralisation(pos,SLICE_STARTER(si));
      else
        do_neutralisation(pos);
    }
  }

  pipe_solve_delegate(si);

  TraceFunctionExit(__func__);
  TraceFunctionResultEnd();
}
Ejemplo n.º 13
0
static void insert_selfcheck_guard_goal(slice_index si,
                                        stip_structure_traversal *st)
{
  in_branch_insertion_state_type * const state = st->param;
  slice_index const tester = SLICE_NEXT2(si);

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

  if (state->last_checked!=SLICE_STARTER(si)
      && get_stip_structure_traversal_state(tester,st)==slice_not_traversed)
  {
    boolean const save_is_instrumented = state->is_branch_instrumented;

    state->in_goal_tester = SLICE_U(si).goal_handler.goal.type;
    state->is_branch_instrumented = false;

    stip_traverse_structure_next_branch(si,st);

    if (!state->is_branch_instrumented)
    {
      slice_index const prototype = alloc_selfcheck_guard_slice();
      goal_branch_insert_slices(tester,&prototype,1);
    }

    state->is_branch_instrumented = save_is_instrumented;
    state->in_goal_tester = no_goal;
  }

  stip_traverse_structure_children_pipe(si,st);

  TraceFunctionExit(__func__);
  TraceFunctionResultEnd();
}
Ejemplo n.º 14
0
static void remember_last_checked(slice_index si, stip_structure_traversal *st)
{
  in_branch_insertion_state_type * const state = st->param;
  Side const save_last_checked = state->last_checked;

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

  assert(SLICE_STARTER(si)!=no_side);
  state->last_checked = SLICE_STARTER(si);
  stip_traverse_structure_children_pipe(si,st);
  state->last_checked = save_last_checked;

  TraceFunctionExit(__func__);
  TraceFunctionResultEnd();
}
Ejemplo n.º 15
0
/* Instrument the solving machinery with slices dealing with selfcheck detection
 * @param si identifies the root of the solving machinery
 */
void solving_insert_selfcheck_guards(slice_index si)
{
  TraceFunctionEntry(__func__);
  TraceFunctionParam("%u",si);
  TraceFunctionParamListEnd();

  TraceStipulation(si);

  solving_impose_starter(si,SLICE_STARTER(si));
  insert_in_branch_guards(si);
  solving_impose_starter(si,SLICE_STARTER(si));
  insert_guards_in_immobility_testers(si);
  solving_impose_starter(si,SLICE_STARTER(si));
  instrument_move_inverters(si);

  TraceFunctionExit(__func__);
  TraceFunctionResultEnd();
}
Ejemplo n.º 16
0
static void instrument_move_generator(slice_index si, stip_structure_traversal *st)
{
  instrumentation_state_type * const state = st->param;
  Side const save_current_side = state->current_side;

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

  if (mummer_measure_length[SLICE_STARTER(si)])
  {
    if (state->ultra_capturing_king)
    {
      slice_index const prototypes[] =
      {
          alloc_testing_pipe(STMummerOrchestrator),
          alloc_pipe(STUltraMummerMeasurerDeadend)
      };
      enum { nr_prototypes = sizeof prototypes / sizeof prototypes[0] };

      assert(st->activity==stip_traversal_activity_testing);
      assert(st->context==stip_traversal_context_help);

      slice_insertion_insert_contextually(si,st->context,prototypes,nr_prototypes);
    }
    else
    {
      slice_index const prototypes[] =
      {
          alloc_testing_pipe(STMummerOrchestrator),
          alloc_pipe(STMummerDeadend)
      };
      enum { nr_prototypes = sizeof prototypes / sizeof prototypes[0] };
      slice_insertion_insert_contextually(si,st->context,prototypes,nr_prototypes);
    }
  }

  state->current_side = SLICE_STARTER(si);
  stip_traverse_structure_children_pipe(si,st);
  state->current_side = save_current_side;

  TraceFunctionExit(__func__);
  TraceFunctionResultEnd();
}
Ejemplo n.º 17
0
/* Instrument a stipulation
 * @param si identifies root slice of stipulation
 */
void mummer_initialise_solving(slice_index si)
{
  instrumentation_state_type state = { false, no_side };
  stip_structure_traversal st;

  TraceFunctionEntry(__func__);
  TraceFunctionParamListEnd();

  TraceStipulation(si);

  solving_impose_starter(si,SLICE_STARTER(si));

  stip_structure_traversal_init(&st,&state);

  /* instrumentation for regular mummer */
  stip_structure_traversal_override_single(&st,
                                           STMoveGenerator,
                                           &instrument_move_generator);
  stip_structure_traversal_override_single(&st,
                                           STMummerOrchestrator,
                                           &spin_off_measuring_branch);
  stip_structure_traversal_override_single(&st,
                                           STMummerDeadend,
                                           &connect_solver_to_tester);
  stip_structure_traversal_override_single(&st,
                                           STExecutingKingCapture,
                                           &stip_structure_visitor_noop);

  if (mummer_strictness[White]!=mummer_strictness_ultra
      && mummer_strictness[Black]!=mummer_strictness_ultra)
    stip_structure_traversal_override_single(&st,
                                             STImmobilityTester,
                                             &stip_structure_visitor_noop);

  /* additional instrumentation for ultra mummer */
  stip_structure_traversal_override_single(&st,
                                           STUltraMummerMeasurerFork,
                                           &instrument_ultra_mummer_measurer_fork);

  stip_traverse_structure(si,&st);

  if (mummer_strictness[White]==mummer_strictness_ultra)
  {
    stip_instrument_observation_validation(si,White,STValidatingObservationUltraMummer);
    stip_instrument_check_validation(si,White,STValidatingObservationUltraMummer);
  }

  if (mummer_strictness[Black]==mummer_strictness_ultra)
  {
    stip_instrument_observation_validation(si,Black,STValidatingObservationUltraMummer);
    stip_instrument_check_validation(si,Black,STValidatingObservationUltraMummer);
  }

  TraceFunctionExit(__func__);
  TraceFunctionResultEnd();
}
Ejemplo n.º 18
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 opponent_king_capture_avoider_solve(slice_index si)
{
  TraceFunctionEntry(__func__);
  TraceFunctionParam("%u",si);
  TraceFunctionParamListEnd();

  pipe_this_move_illegal_if(si,is_king_captured(advers(SLICE_STARTER(si))));

  TraceFunctionExit(__func__);
  TraceFunctionResultEnd();
}
Ejemplo n.º 19
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 republican_king_placer_solve(slice_index si)
{
  move_effect_journal_index_type const save_horizon = king_square_horizon;

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

  update_king_squares();

  if (being_solved.king_square[advers(SLICE_STARTER(si))]==initsquare)
  {
    determine_king_placement(SLICE_STARTER(si));

    if (king_placement[nbply]==king_not_placed)
    {
      pipe_solve_delegate(si);
      king_placement[nbply] = to_be_initialised;
    }
    else
    {
      place_king(SLICE_STARTER(si));
      pipe_solve_delegate(si);

      if (!post_move_iteration_locked[nbply])
      {
        is_mate_square_dirty[nbply] = true;
        lock_post_move_iterations();
      }
    }

    prev_post_move_iteration_id[nbply] = post_move_iteration_id[nbply];
  }
  else
    pipe_solve_delegate(si);

  king_square_horizon = save_horizon;

  TraceFunctionExit(__func__);
  TraceFunctionResultEnd();
}
Ejemplo n.º 20
0
void remember_detector(slice_index si, stip_structure_traversal *st)
{
  instrumentation_state_type * const state = st->param;

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

  stip_traverse_structure_children(si,st);

  if (SLICE_STARTER(si)==no_side /* just inserted */
      && state->past_detector==no_slice)
  {
    SLICE_STARTER(si) = state->side;
    state->past_detector = alloc_proxy_slice();
    pipe_append(si,state->past_detector);
  }

  TraceFunctionExit(__func__);
  TraceFunctionResultEnd();
}
Ejemplo n.º 21
0
static void insert_selfcheck_guard_branch(slice_index si,
                                          stip_structure_traversal *st)
{
  in_branch_insertion_state_type const * const state = st->param;

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

  if (!state->is_branch_instrumented)
  {
    slice_index const prototype = alloc_selfcheck_guard_slice();
    SLICE_STARTER(prototype) = SLICE_STARTER(si);
    slice_insertion_insert_contextually(si,st->context,&prototype,1);
  }

  stip_traverse_structure_children_pipe(si,st);

  TraceFunctionExit(__func__);
  TraceFunctionResultEnd();
}
Ejemplo n.º 22
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 own_king_capture_avoider_solve(slice_index si)
{
  Side const starter = SLICE_STARTER(si);

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

  pipe_this_move_illegal_if(si,is_king_captured(starter));

  TraceFunctionExit(__func__);
  TraceFunctionResultEnd();
}
Ejemplo n.º 23
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 ohneschach_stop_if_check_solve(slice_index si)
{
  TraceFunctionEntry(__func__);
  TraceFunctionParam("%u",si);
  TraceFunctionParamListEnd();

  if (is_in_check(SLICE_STARTER(si)))
    solve_result = previous_move_is_illegal;
  else
    pipe_solve_delegate(si);

  TraceFunctionExit(__func__);
  TraceFunctionResultEnd();
}
Ejemplo n.º 24
0
static void keepmating_filter_inserter_goal(slice_index si,
                                            stip_structure_traversal *st)
{
  insertion_state_type * const state = st->param;

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

  state->for_side[advers(SLICE_STARTER(si))] = true;

  TraceFunctionExit(__func__);
  TraceFunctionResultEnd();
}
Ejemplo n.º 25
0
static void keepmating_filter_inserter_help(slice_index si,
                                            stip_structure_traversal *st)
{
  insertion_state_type const * const state = st->param;

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

  stip_traverse_structure_children_pipe(si,st);

  {
    slice_index const prototype = alloc_appropriate_filter(state);
    if (prototype!=no_slice)
    {
      SLICE_STARTER(prototype) = advers(SLICE_STARTER(si));
      help_branch_insert_slices(si,&prototype,1);
    }
  }

  TraceFunctionExit(__func__);
  TraceFunctionResultEnd();
}
Ejemplo n.º 26
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 selfcheck_guard_solve(slice_index si)
{
  TraceFunctionEntry(__func__);
  TraceFunctionParam("%u",si);
  TraceFunctionParamListEnd();

  if (is_in_check(advers(SLICE_STARTER(si))))
    solve_result = previous_move_is_illegal;
  else
    pipe_solve_delegate(si);

  TraceFunctionExit(__func__);
  TraceFunctionResultEnd();
}
Ejemplo n.º 27
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 move_generator_solve(slice_index si)
{
  TraceFunctionEntry(__func__);
  TraceFunctionParam("%u",si);
  TraceFunctionParamListEnd();

  nextply(SLICE_STARTER(si));
  genmove();
  pipe_solve_delegate(si);
  finply();

  TraceFunctionExit(__func__);
  TraceFunctionResultEnd();
}
Ejemplo n.º 28
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 amu_attack_counter_solve(slice_index si)
{
  square const sq_departure = move_generation_stack[CURRMOVE_OF_PLY(nbply)].departure;
  Side const starter = SLICE_STARTER(si);

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

  amu_attacked_exactly_once[nbply] = is_attacked_exactly_once(sq_departure,starter);
  pipe_solve_delegate(si);

  TraceFunctionExit(__func__);
  TraceFunctionResultEnd();
}
Ejemplo n.º 29
0
static void determine_need_for_move_inverter_instrumentation(slice_index si,
                                                             stip_structure_traversal *st)
{
  move_inverter_instrumentation_state_type * const state = st->param;

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

  stip_traverse_structure_children_pipe(si,st);
  state->guard_needed = state->last_guarded_side!=no_side && SLICE_STARTER(si)!=state->last_guarded_side;

  TraceFunctionExit(__func__);
  TraceFunctionResultEnd();
}
Ejemplo n.º 30
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 maxthreatlength_guard_solve(slice_index si)
{
  stip_length_type const n_max = slack_length+2*max_len_threat;

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

  pipe_this_move_doesnt_solve_if(si,
                                 solve_nr_remaining>=n_max
                                 && !is_in_check(SLICE_STARTER(si))
                                 && n_max<testing_pipe_solve_delegate(si,n_max));

  TraceFunctionExit(__func__);
  TraceFunctionResultEnd();
}