Example #1
0
/* Inialise the observation machinery with transmuting kings
 * @param si identifies root slice of solving machinery
 * @param side for whom
 * @note invoked by transmuting_kings_initialise_observing()
 */
void transmuting_kings_initialise_observing(slice_index si, Side side)
{
  TraceFunctionEntry(__func__);
  TraceFunctionParam("%u",si);
  TraceEnumerator(Side,side);
  TraceFunctionParamListEnd();

  {
    instrumentation_state_type state = { side, no_slice  };
    stip_structure_traversal st;

    stip_structure_traversal_init(&st,&state);
    stip_structure_traversal_override_single(&st,
                                             STTestingIfSquareIsObserved,
                                             &instrument_testing);
    stip_structure_traversal_override_single(&st,
                                             STTransmutingKingDetectNonTransmutation,
                                             &remember_detector);
    stip_traverse_structure(si,&st);
  }

  stip_instrument_observation_validation(si,side,STTransmutingKingsEnforceObserverWalk);
  stip_instrument_check_validation(si,side,STTransmutingKingsEnforceObserverWalk);

  TraceFunctionExit(__func__);
  TraceFunctionResultEnd();
}
Example #2
0
/* Instrument a stipulation
 * @param si identifies root slice of stipulation
 */
void solving_insert_republican_king_placers(slice_index si)
{
  stip_structure_traversal st;

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

  stip_structure_traversal_init(&st,0);
  stip_structure_traversal_override_single(&st,
                                           STMove,
                                           &instrument_move);
  stip_structure_traversal_override_single(&st,
                                           STTemporaryHackFork,
                                           &stip_traverse_structure_children_pipe);
  if (RepublicanType==ConditionType1)
    stip_structure_traversal_override_single(&st,
                                             STGoalReachedTester,
                                             &stip_traverse_structure_children_pipe);
  stip_traverse_structure(si,&st);

  if (RepublicanType==ConditionType1)
    insert_type1_dead_end(si);

  TraceFunctionExit(__func__);
  TraceFunctionResultEnd();
}
Example #3
0
/* Instrument the solvers with Patrol Chess
 * @param si identifies the root slice of the stipulation
 */
void solving_insert_take_and_make(slice_index si)
{
  stip_structure_traversal st;
  boolean collecting_rebirth_squares = false;

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

  TraceStipulation(si);

  stip_structure_traversal_init(&st,&collecting_rebirth_squares);

  stip_structure_traversal_override_single(&st,
                                           STExecutingKingCapture,
                                           &stip_structure_visitor_noop);

  if (CondFlag[normalp])
    stip_structure_traversal_override_single(&st,
                                             STDoneGeneratingMoves,
                                             &insert_make_generator);
  else
    /* Extra rule: pawns must not 'make' to their base line */
    stip_structure_traversal_override_single(&st,
                                             STDoneGeneratingMoves,
                                             &insert_make_generator_avoid_pawn_to_baseline);

  stip_traverse_structure(si,&st);

  TraceFunctionExit(__func__);
  TraceFunctionResultEnd();
}
Example #4
0
/* Initialise solving with BGL
 */
void bgl_initialise_solving(slice_index si)
{
  TraceFunctionEntry(__func__);
  TraceFunctionParamListEnd();

  {
    stip_structure_traversal st;
    stip_structure_traversal_init(&st,0);
    stip_structure_traversal_override_single(&st,
                                             STDoneGeneratingMoves,
                                             &insert_remover);
    stip_traverse_structure(si,&st);
  }

  {
    stip_structure_traversal st;
    stip_structure_traversal_init(&st,0);
    stip_structure_traversal_override_single(&st,STMove,&instrument_move);
    stip_traverse_structure(si,&st);
  }

  if (BGL_values[White]!=BGL_infinity)
  {
    stip_instrument_observation_validation(si,White,STBGLEnforcer);
    stip_instrument_check_validation(si,White,STBGLEnforcer);
  }
  if (BGL_values[Black]!=BGL_infinity)
  {
    stip_instrument_observation_validation(si,Black,STBGLEnforcer);
    stip_instrument_check_validation(si,Black,STBGLEnforcer);
  }

  TraceFunctionExit(__func__);
  TraceFunctionResultEnd();
}
Example #5
0
/* Initialise the solving machinery with Extinction Chess
 * @param si identifies root slice of stipulation
 */
void extinction_initialise_solving(slice_index si)
{
  TraceFunctionEntry(__func__);
  TraceFunctionParam("%u",si);
  TraceFunctionParamListEnd();

  /* we have to actually play potentially extincting moves to find out whether
   * they really are in conditions such as Circe
   */
  stip_instrument_check_validation(si,
                                   nr_sides,
                                   STValidateCheckMoveByPlayingCapture);

  {
    stip_structure_traversal st;
    stip_structure_traversal_init(&st,0);
    stip_structure_traversal_override_single(&st,
                                             STGoalKingCaptureReachedTester,
                                             &substitute_extinction_tester);
    stip_structure_traversal_override_single(&st,
                                             STKingSquareObservationTester,
                                             &substitute_all_pieces_observation_tester);
    stip_traverse_structure(si,&st);
  }

  check_even_if_no_king();

  TraceFunctionExit(__func__);
  TraceFunctionResultEnd();
}
Example #6
0
/* Inialise the solving machinery with Face-to-face Chess
 * @param si identifies root slice of solving machinery
 */
static void initialise_solving(slice_index si,
                               slice_type generator,
                               slice_type enforcer)
{
  TraceFunctionEntry(__func__);
  TraceFunctionParamListEnd();

  solving_instrument_move_generation(si,nr_sides,generator);

  {
    stip_structure_traversal st;
    stip_structure_traversal_init(&st,&enforcer);
    stip_structure_traversal_override_single(&st,
                                             STEnforceObserverWalk,
                                             &substitute_enforce_confronted_walk);
    stip_structure_traversal_override_single(&st,
                                             STValidatingObserver,
                                             &stip_structure_visitor_noop);
    stip_structure_traversal_override_single(&st,
                                             STValidatingObservationGeometry,
                                             &stip_structure_visitor_noop);
    stip_traverse_structure(si,&st);
  }

  TraceFunctionExit(__func__);
  TraceFunctionResultEnd();
}
Example #7
0
/* Create the root slices of a battle branch
 * @param adapter identifies the adapter slice at the beginning of the branch
 * @param state address of structure holding state
 */
void battle_branch_make_root_slices(slice_index adapter,
                                    spin_off_state_type *state)
{
  TraceFunctionEntry(__func__);
  TraceFunctionParam("%u",adapter);
  TraceFunctionParamListEnd();

  {
    stip_structure_traversal st;

    stip_structure_traversal_init(&st,state);
    stip_structure_traversal_override_by_structure(&st,
                                                   slice_structure_leaf,
                                                   &leaf_spin_off_copy);
    stip_structure_traversal_override_by_structure(&st,
                                                   slice_structure_pipe,
                                                   &pipe_spin_off_copy);
    stip_structure_traversal_override_by_structure(&st,
                                                   slice_structure_branch,
                                                   &pipe_spin_off_copy);
    stip_structure_traversal_override_by_structure(&st,
                                                   slice_structure_fork,
                                                   &fork_make_root);
    stip_structure_traversal_override_by_contextual(&st,
                                                    slice_contextual_binary,
                                                    &binary_make_root);
    stip_structure_traversal_override_by_contextual(&st,
                                                    slice_contextual_conditional_pipe,
                                                    &conditional_pipe_spin_off_copy);
    stip_structure_traversal_override_single(&st,
                                             STReadyForDefense,
                                             &ready_for_defense_make_root);
    stip_structure_traversal_override_single(&st,
                                             STConstraintTester,
                                             &constraint_tester_make_root);
    stip_structure_traversal_override_single(&st,
                                             STGoalConstraintTester,
                                             &goal_constraint_tester_make_root);
    stip_structure_traversal_override_single(&st,
                                             STReadyForDefense,
                                             &ready_for_defense_make_root);
    stip_structure_traversal_override_single(&st,
                                             STEndOfRoot,
                                             &serve_as_root_hook);
    stip_traverse_structure(adapter,&st);
  }

  TraceFunctionExit(__func__);
  TraceFunctionParamListEnd();
}
Example #8
0
static void insert_promoters(slice_index si)
{
  stip_structure_traversal st;
  slice_index landing = no_slice;

  TraceFunctionEntry(__func__);
  TraceFunctionParamListEnd();

  stip_structure_traversal_init(&st,&landing);
  stip_structure_traversal_override_single(&st,STBeforePawnPromotion,&instrument_promotion);
  stip_structure_traversal_override_single(&st,STLandingAfterPawnPromotion,&remember_landing);
  stip_traverse_structure(si,&st);

  TraceFunctionExit(__func__);
  TraceFunctionResultEnd();
}
Example #9
0
/*
 *  Instrument the solving machinery with slices that write the solution in
 * plain text
 */
void output_plaintext_instrument_solving(slice_index si)
{
  stip_structure_traversal st;

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

  TraceStipulation(si);

  stip_structure_traversal_init(&st,0);
  stip_structure_traversal_override_single(&st,
                                           STOutputModeSelector,
                                           &visit_output_mode_selector);
  stip_traverse_structure(si,&st);

  {
    slice_index const prototypes[] =
    {
        alloc_output_plaintext_end_of_phase_writer_slice()
    };
    enum
    {
      nr_prototypes = sizeof prototypes / sizeof prototypes[0]
    };
    slice_insertion_insert(si,prototypes,nr_prototypes);
  }

  solving_insert_move_inversion_counter_slices(si);

  pipe_solve_delegate(si);

  TraceFunctionExit(__func__);
  TraceFunctionResultEnd();
}
Example #10
0
/* Remember the id of the piece to be kissed
 * @param si root of the solving machinery
 */
void goal_kiss_init_piece_id(slice_index si)
{
  stip_structure_traversal st;
  stip_structure_traversal_init(&st,0);
  stip_structure_traversal_override_single(&st,STGoalReachedTester,&remember_id);
  stip_traverse_structure(si,&st);
}
Example #11
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();
}
Example #12
0
/* Instrument slices with move tracers
 */
void solving_insert_imitator(slice_index si)
{
  TraceFunctionEntry(__func__);
  TraceFunctionParamListEnd();

  {
    stip_structure_traversal st;
    stip_structure_traversal_init(&st,0);
    stip_structure_traversal_override_single(&st,
                                             STDoneGeneratingMoves,
                                             &insert_remover);
    stip_traverse_structure(si,&st);
  }

  if (!CondFlag[noiprom])
    insert_promoters(si);

  stip_instrument_moves(si,STImitatorMover);
  stip_instrument_moves(si,STImitatorDetectIllegalMoves);

  stip_instrument_observation_geometry_validation(si,
                                                  nr_sides,
                                                  STImitatorRemoveIllegalMoves);

  TraceFunctionExit(__func__);
  TraceFunctionResultEnd();
}
Example #13
0
/* Attempt to apply the postkey play option to the current stipulation
 * @param root_proxy identifies root proxy slice
 * @return true iff postkey play option is applicable (and has been
 *              applied)
 */
static boolean battle_branch_apply_postkeyplay(slice_index root_proxy)
{
  boolean result;
  slice_index postkey_slice = no_slice;
  stip_structure_traversal st;

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

  TraceStipulation(root_proxy);

  stip_structure_traversal_init(&st,&postkey_slice);
  stip_structure_traversal_override_by_structure(&st,
                                                 slice_structure_pipe,
                                                 &move_to_postkey);
  stip_structure_traversal_override_by_contextual(&st,
                                                  slice_contextual_testing_pipe,
                                                  &move_to_postkey);
  stip_structure_traversal_override_single(&st,
                                           STAttackAdapter,
                                           &attack_adapter_make_postkeyplay);
  stip_structure_traversal_override_single(&st,
                                           STHelpAdapter,
                                           &stip_structure_visitor_noop);
  stip_traverse_structure_children_pipe(root_proxy,&st);

  if (postkey_slice==no_slice)
    result = false;
  else
  {
    link_to_branch(root_proxy,postkey_slice);

    {
      slice_index const prototype = alloc_move_inverter_slice();
      slice_insertion_insert(root_proxy,&prototype,1);
    }

    result = true;
  }

  TraceFunctionExit(__func__);
  TraceFunctionParam("%u",result);
  TraceFunctionParamListEnd();
  return result;
}
Example #14
0
/* Spin off slices for testing whethere there is a solution
 * @param si root slice of the stipulation
 */
void solving_spin_off_testers(slice_index si)
{
  stip_structure_traversal st;

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

  TraceStipulation(si);

  stip_structure_traversal_init(&st,0);

  stip_structure_traversal_override_by_structure(&st,
                                                 slice_structure_pipe,
                                                 &stip_spin_off_testers_pipe);
  stip_structure_traversal_override_by_structure(&st,
                                                 slice_structure_branch,
                                                 &stip_spin_off_testers_pipe);
  stip_structure_traversal_override_by_structure(&st,
                                                 slice_structure_fork,
                                                 &stip_spin_off_testers_fork);
  stip_structure_traversal_override_by_structure(&st,
                                                 slice_structure_leaf,
                                                 &stip_spin_off_testers_leaf);
  stip_structure_traversal_override_by_contextual(&st,
                                                  slice_contextual_binary,
                                                  &stip_spin_off_testers_binary);
  stip_structure_traversal_override_by_contextual(&st,
                                                  slice_contextual_testing_pipe,
                                                  &stip_spin_off_testers_testing_pipe);
  stip_structure_traversal_override_by_contextual(&st,
                                                  slice_contextual_conditional_pipe,
                                                  &stip_spin_off_testers_conditional_pipe);

  stip_structure_traversal_override_single(&st,STTemporaryHackFork,&stip_spin_off_testers_pipe_skip);

  stip_structure_traversal_override_single(&st,STPlaySuppressor,&stip_spin_off_testers_pipe_skip);
  stip_structure_traversal_override_single(&st,STIfThenElse,&stip_spin_off_testers_if_then_else);

  stip_traverse_structure(si,&st);

  TraceFunctionExit(__func__);
  TraceFunctionResultEnd();
}
Example #15
0
/* Has the input branch already been instrumend with a proofgame solver?
 * @param start entry into input branch
 * @return true iff input branch has already been instrumend
 */
boolean input_is_instrumented_with_proof(slice_index start)
{
  boolean result = false;
  stip_structure_traversal st;

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

  stip_structure_traversal_init(&st,&result);
  stip_structure_traversal_override_single(&st,STProofSolverBuilder,&report_instrumented);
  stip_structure_traversal_override_single(&st,STAToBSolverBuilder,&report_instrumented);
  stip_structure_traversal_override_single(&st,STStartOfCurrentTwin,&stip_structure_visitor_noop);
  stip_traverse_structure(start,&st);

  TraceFunctionExit(__func__);
  TraceFunctionResult("%u",result);
  TraceFunctionResultEnd();
  return result;
}
Example #16
0
/* Notify the output machinery about a twinning event
 * @param si identifies the slice that detected the twinning (at the same time
 *           to be used as the starting point of any instrumentation)
 * @param stage the twinning event
 * @param continued is the twin continued?
 */
void output_notify_twinning(slice_index si,
                            twinning_event_type event,
                            boolean continued)
{
  stip_structure_traversal st;
  notification_struct e = { event, continued };

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

  stip_structure_traversal_init(&st,&e);
  stip_structure_traversal_override_single(&st,STOutputPlaintextTwinIntroWriterBuilder,&notify_medium);
  stip_structure_traversal_override_single(&st,STOutputLaTeXTwinningWriterBuilder,&notify_medium);
  stip_traverse_structure(si,&st);

  TraceFunctionExit(__func__);
  TraceFunctionResultEnd();
}
Example #17
0
/* Instrument the solving machinery for BlackChecks
 * @param si identifies root slice of stipulation
 */
void blackchecks_initialise_solving(slice_index si)
{
  stip_structure_traversal st;
  slice_index landing = no_slice;

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

  stip_structure_traversal_init(&st,&landing);
  stip_structure_traversal_override_single(&st,STGoalReachedTester,&stip_structure_visitor_noop);
  stip_structure_traversal_override_single(&st,STMove,&instrument_move);
  stip_structure_traversal_override_single(&st,STGeneratingMoves,&instrument_move_generator);
  stip_structure_traversal_override_single(&st,
                                           STLandingAfterMovingPieceMovement,
                                           &remember_landing);
  stip_traverse_structure(si,&st);

  TraceFunctionExit(__func__);
  TraceFunctionResultEnd();
}
Example #18
0
/* Instrument the solving machinery with king capture avoiders
 * @param si identifies root slice of the solving machinery
 */
void solving_insert_king_capture_avoiders(slice_index si)
{
  insertion_state state = root_state;
  stip_structure_traversal st;

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

  stip_structure_traversal_init(&st,&state);
  stip_structure_traversal_override_single(&st,
                                           STMove,
                                           &instrument_move);
  stip_structure_traversal_override_single(&st,
                                           STGoalCounterMateReachedTester,
                                           &remember_goal_with_potential_king_capture);
  stip_structure_traversal_override_single(&st,
                                           STGoalDoubleMateReachedTester,
                                           &remember_goal_with_potential_king_capture);
  stip_structure_traversal_override_single(&st,
                                           STBrunnerDefenderFinder,
                                           &stip_traverse_structure_children_pipe);
  stip_structure_traversal_override_single(&st,
                                           STKingCaptureLegalityTester,
                                           &stip_traverse_structure_children_pipe);
  stip_structure_traversal_override_single(&st,
                                           STMoveLegalityTester,
                                           &stip_traverse_structure_children_pipe);
  stip_traverse_structure(si,&st);

  TraceFunctionExit(__func__);
  TraceFunctionResultEnd();
}
Example #19
0
/* Create the root slices of a help branch
 * @param adapter identifies the adapter slice at the beginning of the branch
 * @param state address of structure holding state
 */
void help_branch_make_root_slices(slice_index adapter,
                                  spin_off_state_type *state)
{
  TraceFunctionEntry(__func__);
  TraceFunctionParam("%u",adapter);
  TraceFunctionParamListEnd();

  {
    stip_structure_traversal st;

    TraceStipulation(adapter);

    stip_structure_traversal_init(&st,state);
    stip_structure_traversal_override_by_structure(&st,
                                                   slice_structure_pipe,
                                                   &pipe_spin_off_copy);
    stip_structure_traversal_override_by_structure(&st,
                                                   slice_structure_branch,
                                                   &pipe_spin_off_copy);
    stip_structure_traversal_override_by_contextual(&st,
                                                    slice_contextual_binary,
                                                    &binary_make_root);
    stip_structure_traversal_override_by_structure(&st,
                                                   slice_structure_fork,
                                                   &fork_make_root);
    stip_structure_traversal_override_by_contextual(&st,
                                                    slice_contextual_conditional_pipe,
                                                    &conditional_pipe_spin_off_copy);
    stip_structure_traversal_override_single(&st,
                                             STConstraintTester,
                                             &constraint_tester_make_root);
    stip_structure_traversal_override_single(&st,STEndOfRoot,&serve_as_root_hook);
    stip_traverse_structure(adapter,&st);
  }

  TraceValue("%u\n",state->spun_off[adapter]);

  TraceFunctionExit(__func__);
  TraceFunctionResultEnd();
}
Example #20
0
/* Instrument the move generation machinery so that there are two paths which
 * can be adapted separately.
 * @param si root slice of solving machinery
 * @param side side for which to instrument; pass nr_sides for both sides
 * @note inserts proxy slices STMoveForPieceGeneratorStandardPath and
 *       STMoveForPieceGeneratorAlternativePath that can be used for adjusting the move
 *       generation
 */
void move_generator_instrument_for_alternative_paths(slice_index si, Side side)
{
  stip_structure_traversal st;

  solving_instrument_move_generation(si,
                                     side,
                                     STMoveForPieceGeneratorPathsJoint);

  stip_structure_traversal_init(&st,0);
  stip_structure_traversal_override_single(&st,
                                           STMoveForPieceGeneratorPathsJoint,
                                           &insert_separator);
  stip_traverse_structure(si,&st);
}
Example #21
0
static void insert_type1_dead_end(slice_index si)
{
  stip_structure_traversal st;

  TraceFunctionEntry(__func__);
  TraceFunctionParamListEnd();

  stip_structure_traversal_init(&st,0);
  stip_structure_traversal_override_single(&st,STMove,&instrument_defense);
  stip_traverse_structure(si,&st);

  TraceFunctionExit(__func__);
  TraceFunctionResultEnd();
}
Example #22
0
static void substitute_single_piece_move_generator(Side side)
{
  stip_structure_traversal st;

  TraceFunctionEntry(__func__);
  TraceFunctionParamListEnd();

  stip_structure_traversal_init(&st,0);
  stip_structure_traversal_override_single(&st,STMoveGenerator,&do_substitute);
  stip_traverse_structure(SLICE_NEXT2(temporary_hack_circe_take_make_rebirth_squares_finder[side]),&st);

  TraceFunctionExit(__func__);
  TraceFunctionResultEnd();
}
Example #23
0
static void insert_enforcers(slice_index si, stip_structure_traversal *st)
{
  TraceFunctionEntry(__func__);
  TraceFunctionParam("%u",si);
  TraceFunctionParamListEnd();

  stip_traverse_structure_children(si,st);

  {
    stip_deep_copies_type copies;
    stip_structure_traversal st_nested;

    slice_index const * const threat_start = st->param;
    slice_index const threat_start_tester = SLICE_TESTER(*threat_start);

    assert(*threat_start!=no_slice);
    assert(threat_start_tester!=no_slice);
    assert(SLICE_TYPE(threat_start_tester)==STThreatStart);

    {
      slice_index const prototype = alloc_pipe(STThreatDefeatedTester);
      attack_branch_insert_slices(threat_start_tester,&prototype,1);
    }

    init_deep_copy(&st_nested,st,&copies);
    stip_structure_traversal_override_single(&st_nested,
                                             STThreatDefeatedTester,
                                             &move_and_stop_copying);
    stip_structure_traversal_override_by_contextual(&st_nested,
                                                    slice_contextual_conditional_pipe,
                                                    &copy_shallow);
    stip_structure_traversal_override_by_contextual(&st_nested,
                                                    slice_contextual_testing_pipe,
                                                    &copy_shallow);
    stip_traverse_structure(threat_start_tester,&st_nested);

    SLICE_NEXT2(si) = copies[threat_start_tester];
  }

  {
    /* if the threats are short, max_unsolvable might interfere with enforcing
     * them */
    slice_index const prototype = alloc_reset_unsolvable_slice();
    attack_branch_insert_slices(SLICE_NEXT2(si),&prototype,1);
  }

  TraceFunctionExit(__func__);
  TraceFunctionResultEnd();
}
Example #24
0
/* Inialise the solving machinery with Anti-Mars Circe
 * @param si identifies root slice of solving machinery
 */
void solving_initialise_antimars(slice_index si)
{
  TraceFunctionEntry(__func__);
  TraceFunctionParamListEnd();

  {
    stip_structure_traversal st;
    stip_structure_traversal_init(&st,0);
    stip_structure_traversal_override_single(&st,
                                             STMoveForPieceGeneratorStandardPath,
                                             &instrument_rebirth);
    stip_structure_traversal_override_single(&st,
                                             STMoveForPieceGeneratorAlternativePath,
                                             &instrument_no_rebirth);
    stip_traverse_structure(si,&st);
  }

  circe_initialise_solving(si,
                           &antimars_variant,
                           STMoveForPieceGeneratorStandardPath,
                           &slice_insertion_insert_contextually,
                           STAntimarsCirceConsideringRebirth);
  circe_instrument_solving(si,
                           STAntimarsCirceConsideringRebirth,
                           STCirceDeterminedRebirth,
                           alloc_pipe(STMarscirceRemoveCapturer));

  if (antimars_variant.rebirth_reason==move_effect_reason_rebirth_choice)
    circe_instrument_solving(si,
                             STAntimarsCirceConsideringRebirth,
                             STAntimarsCirceConsideringRebirth,
                             alloc_pipe(STMoveGenerationPostMoveIterator));

  TraceFunctionExit(__func__);
  TraceFunctionResultEnd();
}
Example #25
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();
}
Example #26
0
/* Execute the optimisations planned before and communicated using a series of
 * invokations of ohneschach_stop_if_check_plan_to_optimise_away_stop()
 * @param root root slice of the stiptulation
 */
void ohneschach_stop_if_check_execute_optimisations(slice_index root)
{
  stip_structure_traversal st;

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

  stip_structure_traversal_init(&st,0);
  stip_structure_traversal_override_single(&st,
                                           STOhneschachStopIfCheckAndNotMate,
                                           &optimise_stop);
  stip_traverse_structure(root,&st);

  TraceFunctionExit(__func__);
  TraceFunctionResultEnd();
}
Example #27
0
static void instrument(slice_index si)
{
  /* we have to actually play potentially assassinating moves
   */
  stip_instrument_check_validation(si,
                                   nr_sides,
                                   STValidateCheckMoveByPlayingCapture);

  {
    stip_structure_traversal st;
    stip_structure_traversal_init(&st,0);
    stip_structure_traversal_override_single(&st,
                                             STKingSquareObservationTester,
                                             &substitute_all_pieces_observation_tester);
    stip_traverse_structure(si,&st);
  }
}
Example #28
0
/* When counting mating moves, it is not necessary to detect self-check in moves
 * that don't deliver mate; remove the slices that would detect these
 * self-checks
 * @param si identifies slice where to start
 */
void optimise_away_unnecessary_selfcheckguards(slice_index si)
{
  stip_structure_traversal st;

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

  stip_structure_traversal_init(&st,0);
  stip_structure_traversal_override_single(&st,
                                           STExclusiveChessMatingMoveCounterFork,
                                           &remove_guard);
  stip_traverse_structure(si,&st);

  TraceFunctionExit(__func__);
  TraceFunctionResultEnd();
}
Example #29
0
/* Produce slices representing set play.
 * This is supposed to be invoked from within the slice type specific
 * functions invoked by stip_apply_setplay.
 * @param adapter identifies the adapter slice into the battle branch
 * @param state address of structure holding state
 */
void battle_branch_make_setplay(slice_index adapter, spin_off_state_type *state)
{
  TraceFunctionEntry(__func__);
  TraceFunctionParam("%u",adapter);
  TraceFunctionParamListEnd();

  {
    slice_index const start = branch_find_slice(STReadyForDefense,
                                                adapter,
                                                stip_traversal_context_intro);
    stip_structure_traversal st;

    slice_index const notend = branch_find_slice(STNotEndOfBranchGoal,
                                                 adapter,
                                                 stip_traversal_context_intro);
    slice_index const prototype = alloc_pipe(STEndOfRoot);
    assert(notend!=no_slice);
    defense_branch_insert_slices(notend,&prototype,1);

    assert(start!=no_slice);

    stip_structure_traversal_init(&st,state);
    st.context = stip_traversal_context_defense;
    stip_structure_traversal_override_by_structure(&st,
                                                   slice_structure_pipe,
                                                   &copy_to_setplay);
    stip_structure_traversal_override_by_structure(&st,
                                                   slice_structure_branch,
                                                   &copy_to_setplay);
    stip_structure_traversal_override_by_structure(&st,
                                                   slice_structure_fork,
                                                   &copy_to_setplay);
    stip_structure_traversal_override_single(&st,STEndOfRoot,&serve_as_root_hook);
    stip_traverse_structure(start,&st);
    TraceValue("%u",state->spun_off[start]);
    TraceEOL();
    state->spun_off[adapter] = state->spun_off[start];
  }

  TraceValue("%u",state->spun_off[adapter]);
  TraceEOL();

  TraceFunctionExit(__func__);
  TraceFunctionParamListEnd();
}
/* Replace immobility tester slices' type
 * @param si where to start (entry slice into stipulation)
 */
void immobility_testers_substitute_king_first(slice_index si)
{
  stip_structure_traversal st;

  TraceFunctionEntry(__func__);
  TraceFunctionParamListEnd();

  TraceStipulation(si);

  stip_structure_traversal_init(&st,0);
  stip_structure_traversal_override_single(&st,
                                           STImmobilityTester,
                                           &substitute_king_first);
  stip_traverse_structure(si,&st);

  TraceFunctionExit(__func__);
  TraceFunctionResultEnd();
}