Exemple #1
0
static void alloc_reci_end(slice_index proxy_nonreci,
                           slice_index proxy_reci,
                           slice_index proxy_to_nonreci,
                           slice_index proxy_to_reci)
{
    TraceFunctionEntry(__func__);
    TraceFunctionParam("%u",proxy_nonreci);
    TraceFunctionParam("%u",proxy_reci);
    TraceFunctionParam("%u",proxy_to_nonreci);
    TraceFunctionParam("%u",proxy_to_reci);
    TraceFunctionParamListEnd();

    {
        slice_index const branch_nonreci = alloc_help_branch(2,2);
        slice_index const branch_reci = alloc_help_branch(1,1);

        help_branch_set_end_goal(branch_nonreci,proxy_to_nonreci,1);
        link_to_branch(proxy_nonreci,branch_nonreci);

        help_branch_set_end_goal(branch_reci,proxy_to_reci,1);
        link_to_branch(proxy_reci,branch_reci);
    }

    TraceFunctionExit(__func__);
    TraceFunctionResultEnd();
}
static slice_index make_cagecirce_noncapture_finder(Side side)
{
  slice_index result;

  if (circe_variant.determine_rebirth_square==circe_determine_rebirth_square_cage
      || anticirce_variant.determine_rebirth_square==circe_determine_rebirth_square_cage)
  {
    slice_index const proxy_branch = alloc_proxy_slice();
    slice_index const help = alloc_help_branch(slack_length+1,slack_length+1);
    slice_index const proxy_goal = alloc_proxy_slice();
    slice_index const system = alloc_goal_capture_reached_tester_system();
    link_to_branch(proxy_goal,system);

    {
      slice_index const tester = branch_find_slice(STGoalReachedTester,
                                                   proxy_goal,
                                                   stip_traversal_context_intro);
      assert(tester!=no_slice);
      pipe_append(SLICE_NEXT2(tester),alloc_not_slice());
      SLICE_U(tester).goal_handler.goal.type = goal_negated;
      help_branch_set_end_goal(help,proxy_goal,1);
      link_to_branch(proxy_branch,help);
      result = alloc_conditional_pipe(STCageCirceNonCapturingMoveFinder,proxy_branch);
      solving_impose_starter(result,side);
    }
  }
  else
    result = alloc_proxy_slice();

  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();
}
static slice_index make_ultra_mummer_length_measurer(Side side)
{
  slice_index result;
  slice_index const proxy_branch = alloc_proxy_slice();
  slice_index const help = alloc_help_branch(slack_length+1,slack_length+1);
  slice_index const proxy_goal = alloc_proxy_slice();
  slice_index const system = alloc_goal_any_reached_tester_system();
  link_to_branch(proxy_goal,system);
  help_branch_set_end_goal(help,proxy_goal,1);
  link_to_branch(proxy_branch,help);
  result = alloc_conditional_pipe(STUltraMummerMeasurerFork,proxy_branch);
  solving_impose_starter(result,side);
  return result;
}
static slice_index make_castling_intermediate_move_legality_tester(Side side)
{
  slice_index result;
  slice_index const proxy_branch = alloc_proxy_slice();
  slice_index const help = alloc_help_branch(slack_length+1,slack_length+1);
  slice_index const proxy_goal = alloc_proxy_slice();
  slice_index const system = alloc_goal_any_reached_tester_system();
  link_to_branch(proxy_goal,system);
  help_branch_set_end_goal(help,proxy_goal,1);
  link_to_branch(proxy_branch,help);
  result = alloc_conditional_pipe(STCastlingIntermediateMoveLegalityTester,proxy_branch);
  solving_impose_starter(result,side);

  return result;
}
static slice_index make_brunner_check_defense_finder(Side side)
{
  slice_index result;
  slice_index const proxy_branch = alloc_proxy_slice();
  slice_index const help = alloc_help_branch(slack_length+1,slack_length+1);
  slice_index const proxy_goal = alloc_proxy_slice();
  slice_index const system = alloc_goal_any_reached_tester_system();
  slice_index const executing = alloc_pipe(STExecutingKingCapture);
  link_to_branch(proxy_goal,system);
  help_branch_set_end_goal(help,proxy_goal,1);
  slice_insertion_insert(help,&executing,1);
  link_to_branch(proxy_branch,help);
  result = alloc_conditional_pipe(STBrunnerDefenderFinder,proxy_branch);
  solving_impose_starter(result,side);
  return result;
}
Exemple #7
0
static void insert_maxthreatlength_guard(slice_index si,
                                         stip_structure_traversal *st)
{
  stip_length_type const length = SLICE_U(si).branch.length;

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

  stip_traverse_structure_children_pipe(si,st);

  if (length>=2*max_len_threat+slack_length)
  {
    boolean * const inserted = st->param;
    slice_index const threat_start = branch_find_slice(STMaxThreatLengthStart,
                                                       si,
                                                       st->context);
    slice_index const proxy = alloc_proxy_slice();
    slice_index const dummy = alloc_pipe(STDummyMove);
    slice_index const played = alloc_defense_played_slice();
    slice_index const prototype = alloc_maxthreatlength_guard(proxy);
    assert(threat_start!=no_slice);
    pipe_link(proxy,dummy);
    pipe_link(dummy,played);
    link_to_branch(played,threat_start);
    defense_branch_insert_slices(si,&prototype,1);

    *inserted = true;
  }

  TraceFunctionExit(__func__);
  TraceFunctionResultEnd();
}
Exemple #8
0
/* Parse a series branch
 * @param tok input token
 * @param min_length minimal number of half moves
 * @param max_length maximal number of half moves
 * @param start index of entry into solving machinery
 * @param proxy index of branch; no_slice if branch couldn't be
 *              parsed
 * @param level nesting level of the operand (0 means top level)
 * @return remainder of input token; 0 if parsing failed
 */
static char *ParseStructuredStip_branch_s(char *tok,
                                          stip_length_type min_length,
                                          stip_length_type max_length,
                                          slice_index start,
                                          slice_index proxy,
                                          unsigned int level)
{
  TraceFunctionEntry(__func__);
  TraceFunctionParam("%s",tok);
  TraceFunctionParam("%u",min_length);
  TraceFunctionParam("%u",max_length);
  TraceFunctionParam("%u",start);
  TraceFunctionParam("%u",proxy);
  TraceFunctionParam("%u",level);
  TraceFunctionParamListEnd();

  {
    slice_index const branch = ParseStructuredStip_make_branch_s(min_length,
                                                                 max_length);
    link_to_branch(proxy,branch);

    tok = ParseStructuredStip_branch_s_operand(tok,start,proxy,level);
    if (tok!=0 && level==0)
      select_output_mode(proxy,output_mode_line);
  }

  TraceFunctionExit(__func__);
  TraceFunctionResult("%s",tok);
  TraceFunctionResultEnd();
  return tok;
}
static slice_index make_opponent_moves_counter_fork(Side side)
{
  slice_index result;

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

  if (is_countnropponentmoves_defense_move_optimisation_enabled(side))
  {
    slice_index const proxy = alloc_proxy_slice();
    slice_index const prototypes[] =
    {
        alloc_opponent_moves_counter_slice(),
        alloc_legal_attack_counter_slice()
    };
    enum { nr_prototypes = sizeof prototypes / sizeof prototypes[0] };
    slice_index const attack = alloc_defense_branch(slack_length+2,slack_length+1);
    slice_insertion_insert(attack,prototypes,nr_prototypes);
    link_to_branch(proxy,attack);
    result = alloc_conditional_pipe(STOpponentMovesCounterFork,proxy);
    solving_impose_starter(result,side);
  }
  else
    result = alloc_proxy_slice();

  TraceFunctionExit(__func__);
  TraceFunctionResult("%u",result);
  TraceFunctionResultEnd();
  return result;
}
Exemple #10
0
static char *ParseHelpDia(char *tok,
                          slice_index start,
                          slice_index proxy,
                          slice_index proxy_next,
                          play_length_type play_length)
{
    char *result;

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

    result = ParseGoal(tok,start,proxy_next);
    if (result!=0)
    {
        stip_length_type length;
        stip_length_type min_length;
        result = ParseHelpLength(result,&length,&min_length,play_length);
        if (result!=0)
        {
            link_to_branch(proxy,alloc_help_branch(length,min_length));
            select_output_mode(proxy,output_mode_line);
            help_branch_set_end_goal(proxy,proxy_next,1);
        }
    }

    TraceFunctionExit(__func__);
    TraceFunctionResult("%s",result);
    TraceFunctionResultEnd();
    return result;
}
Exemple #11
0
/* Instrument a help branch with a STIfThenElse slice
 * @param adapter identifies adapter slice into the help branch
 */
void help_branch_insert_check_zigzag(slice_index adapter)
{
  TraceFunctionEntry(__func__);
  TraceFunctionParam("%u",adapter);
  TraceFunctionParamListEnd();

  {
    slice_index const ready = help_branch_locate_ready(adapter);
    slice_index const proxy1 = alloc_proxy_slice();
    slice_index const proxy2 = alloc_proxy_slice();
    slice_index const played = alloc_help_move_played_slice();
    slice_index const condition = alloc_goal_check_reached_tester_slice(goal_applies_to_starter);
    slice_index const jump = alloc_if_then_else_slice(proxy1,proxy2,condition);
    slice_index const landing_proto = alloc_pipe(STCheckZigzagLanding);

    assert(ready!=no_slice);
    pipe_link(condition,alloc_true_slice());
    help_branch_insert_slices(ready,&landing_proto,1);
    pipe_link(proxy2,SLICE_NEXT1(ready));
    pipe_link(proxy1,played);
    pipe_link(ready,jump);

    {
      slice_index const landing = branch_find_slice(STCheckZigzagLanding,
                                                    ready,
                                                    stip_traversal_context_help);
      assert(landing!=no_slice);
      link_to_branch(played,landing);
    }
  }

  TraceFunctionExit(__func__);
  TraceFunctionResultEnd();
}
Exemple #12
0
static char *ParseSeries(char *tok,
                         slice_index start,
                         slice_index proxy,
                         slice_index proxy_goal,
                         play_length_type play_length)
{
    char *result;

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

    result = ParseGoal(tok,start,proxy_goal);
    if (result!=0)
    {
        stip_length_type length;
        stip_length_type min_length;
        result = ParseSeriesLength(result,&length,&min_length,play_length);
        if (result!=0)
        {
            slice_index const branch = alloc_series_branch(length,min_length);
            link_to_branch(proxy,branch);
            select_output_mode(proxy,output_mode_line);
        }
    }

    TraceFunctionExit(__func__);
    TraceFunctionResult("%s",result);
    TraceFunctionResultEnd();
    return result;
}
static slice_index make_exclusive_mating_move_counter_fork(Side side)
{
  slice_index result;
  slice_index const proxy_branch = alloc_proxy_slice();
  slice_index const proxy_to_goal = alloc_proxy_slice();
  Goal const goal = { goal_mate, initsquare };
  slice_index const tester_system = alloc_goal_mate_reached_tester_system();
  slice_index const tester_slice = alloc_goal_reached_tester_slice(goal,tester_system);
  slice_index const attack = alloc_battle_branch(slack_length+1,slack_length+1);
  slice_index const counter = alloc_pipe(STExclusiveChessGoalReachingMoveCounter);
  link_to_branch(counter,tester_slice);
  link_to_branch(proxy_to_goal,counter);
  link_to_branch(proxy_branch,attack);
  battle_branch_insert_direct_end_of_branch_goal(attack,proxy_to_goal);
  result = alloc_conditional_pipe(STExclusiveChessMatingMoveCounterFork,proxy_branch);
  solving_impose_starter(result,side);
  return result;
}
Exemple #14
0
static void insert_null_move_handler(slice_index si, stip_structure_traversal *st)
{
  slice_index const * const landing = st->param;
  slice_index const proxy = alloc_proxy_slice();
  slice_index const prototype = alloc_null_move_player_slice(proxy);

  assert(*landing!=no_slice);
  link_to_branch(proxy,*landing);

  move_insert_slices(si,st->context,&prototype,1);
}
static slice_index make_suffocation_by_paralysis_detector(Side side)
{
  slice_index const proxy = alloc_proxy_slice();
  slice_index const result = alloc_conditional_pipe(STPiecesParalysingSuffocationFinderFork,proxy);
  slice_index const attack = alloc_battle_branch(slack_length+1,slack_length+1);
  slice_index const prototype = alloc_pipe(STPiecesParalysingSuffocationFinder);
  slice_insertion_insert(attack,&prototype,1);
  link_to_branch(proxy,attack);
  solving_impose_starter(result,side);
  return result;
}
Exemple #16
0
static void attach_help_branch(stip_length_type length,
                               slice_index proxy,
                               slice_index branch)
{
    TraceFunctionEntry(__func__);
    TraceFunctionParam("%u",length);
    TraceFunctionParam("%u",proxy);
    TraceFunctionParam("%u",branch);
    TraceFunctionParamListEnd();

    if (length%2==1)
    {
        slice_index const inverter = alloc_move_inverter_slice();
        pipe_link(proxy,inverter);
        link_to_branch(inverter,branch);
    }
    else
        link_to_branch(proxy,branch);

    TraceFunctionExit(__func__);
    TraceFunctionResultEnd();
}
Exemple #17
0
/* Callback to stip_spin_off_testers
 * Spin a tester slice off a fork slice
 * @param si identifies the testing pipe slice
 * @param st address of structure representing traversal
 */
void stip_spin_off_testers_fork(slice_index si, stip_structure_traversal *st)
{
  TraceFunctionEntry(__func__);
  TraceFunctionParam("%u",si);
  TraceFunctionParamListEnd();

  SLICE_TESTER(si) = copy_slice(si);
  stip_traverse_structure_children(si,st);
  link_to_branch(SLICE_TESTER(si),SLICE_TESTER(SLICE_NEXT1(si)));
  SLICE_NEXT2(SLICE_TESTER(si)) = SLICE_TESTER(SLICE_NEXT2(si));

  TraceFunctionExit(__func__);
  TraceFunctionResultEnd();
}
static slice_index make_circe_take_make_rebirth_squares_finder(Side side)
{
  slice_index result;
  slice_index const proxy_branch = alloc_proxy_slice();
  slice_index const help = alloc_help_branch(slack_length+1,slack_length+1);
  slice_index const prototype = alloc_pipe(STTakeMakeCirceCollectRebirthSquares);
  slice_index const executing = alloc_pipe(STExecutingKingCapture);
  link_to_branch(proxy_branch,help);
  help_branch_insert_slices(help,&prototype,1);
  slice_insertion_insert(help,&executing,1);
  result = alloc_conditional_pipe(STTakeMakeCirceCollectRebirthSquaresFork,proxy_branch);
  solving_impose_starter(result,side);

  return result;
}
static slice_index make_back_home_finder(Side side)
{
  slice_index const proxy = alloc_proxy_slice();
  slice_index const result = alloc_conditional_pipe(STBackHomeFinderFork,proxy);
  slice_index const defense = alloc_defense_branch(slack_length+1,slack_length+1);
  slice_index const prototypes[] =
  {
      alloc_pipe(STBackHomeMovesOnly),
      alloc_legal_defense_counter_slice()
  };
  slice_insertion_insert(defense,prototypes,2);
  link_to_branch(proxy,defense);
  solving_impose_starter(result,side);
  return result;
}
static slice_index make_check_tester(void)
{
  slice_index const proxy = alloc_proxy_slice();
  slice_index const result = alloc_conditional_pipe(STCheckTesterFork,proxy);
  slice_index const testing = alloc_pipe(STTestingCheck);
  slice_index const initialiser = alloc_pipe(STKingSquareObservationTesterPlyInitialiser);
  slice_index const king_square_observation_tester = alloc_pipe(STKingSquareObservationTester);
  slice_index const tested = create_slice(STTestedCheck);
  link_to_branch(proxy,testing);
  pipe_append(testing,initialiser);
  pipe_append(initialiser,king_square_observation_tester);
  pipe_link(king_square_observation_tester,tested);
  solving_impose_starter(result,Black);
  return result;
}
Exemple #21
0
/* End copying on the visited slice, by moving it to the copy and linking it
 * to a proxy slice that takes its original place
 * @param si visited slice
 * @param st structure representing the copying traversal
 */
static void move_and_stop_copying(slice_index si, stip_structure_traversal *st)
{
  stip_deep_copies_type * const copies = st->param;

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

  assert((*copies)[si]==no_slice);
  (*copies)[si] = copy_slice(si);
  pipe_substitute(si,alloc_proxy_slice());
  link_to_branch((*copies)[si],si);

  TraceFunctionExit(__func__);
  TraceFunctionResultEnd();
}
Exemple #22
0
/* Parse a help branch
 * @param tok input token
 * @param min_length minimal number of half moves
 * @param max_length maximal number of half moves
 * @param start index of entry into solving machinery
 * @param proxy index of branch; no_slice if branch couldn't be
 *              parsed
 * @param level nesting level of the operand (0 means top level)
 * @return remainder of input token; 0 if parsing failed
 */
static char *ParseStructuredStip_branch_h(char *tok,
                                          stip_length_type min_length,
                                          stip_length_type max_length,
                                          slice_index start,
                                          slice_index proxy,
                                          unsigned int level)
{
  TraceFunctionEntry(__func__);
  TraceFunctionParam("%s",tok);
  TraceFunctionParam("%u",min_length);
  TraceFunctionParam("%u",max_length);
  TraceFunctionParam("%u",start);
  TraceFunctionParam("%u",proxy);
  TraceFunctionParam("%u",level);
  TraceFunctionParamListEnd();

  {
    boolean parry = false;
    slice_index const branch = ParseStructuredStip_make_branch_h(min_length,
                                                                 max_length);
    link_to_branch(proxy,branch);

    tok = ParseStructuredStip_branch_h_operand(tok,start,proxy,max_length,level);

    if (tok!=0 && token_starts_with("?+?",tok))
    {
      tok += 3;
      parry = true;
    }

    if (tok!=0 && tok[0]=='h')
    {
      tok = ParseStructuredStip_branch_h_operand(tok+1,start,proxy,max_length+1,level);
      if (parry)
        help_branch_insert_check_zigzag(proxy);
      if (level==0)
        select_output_mode(proxy,output_mode_line);
    }
    else
      tok = 0;
  }

  TraceFunctionExit(__func__);
  TraceFunctionResult("%s",tok);
  TraceFunctionResultEnd();
  return tok;
}
Exemple #23
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;
}
Exemple #24
0
/* Instrument a battle branch with a STIfThenElse slice providing a
 * shortcut for the defense moe
 * @param adapter identifies adapter slice into the battle branch
 */
void battle_branch_insert_defense_check_zigzag(slice_index adapter)
{
  TraceFunctionEntry(__func__);
  TraceFunctionParam("%u",adapter);
  TraceFunctionParamListEnd();

  {
    slice_index const ready = branch_find_slice(STReadyForDefense,
                                                adapter,
                                                stip_traversal_context_intro);
    slice_index const deadend = branch_find_slice(STDeadEnd,
                                                  ready,
                                                  stip_traversal_context_defense);
    slice_index const proxy1 = alloc_proxy_slice();
    slice_index const proxy2 = alloc_proxy_slice();
    slice_index const dummy = alloc_pipe(STDummyMove);
    slice_index const played = alloc_defense_played_slice();
    slice_index const condition = alloc_goal_check_reached_tester_slice(goal_applies_to_starter);
    slice_index const jump = alloc_if_then_else_slice(proxy1,proxy2,condition);
    slice_index const landing_proto = alloc_pipe(STCheckZigzagLanding);

    assert(ready!=no_slice);
    assert(deadend!=no_slice);
    pipe_link(condition,alloc_true_slice());
    defense_branch_insert_slices(ready,&landing_proto,1);
    pipe_link(proxy2,SLICE_NEXT1(deadend));
    /* the dummy move is needed to make sure that the killer move mechanism
     * applies to the same play whether the attacker has delivered check or not
     * TODO only insert the dummy move if the killer move optimisation is used
     */
    pipe_link(proxy1,dummy);
    pipe_link(dummy,played);
    pipe_link(deadend,jump);

    {
      slice_index const landing = branch_find_slice(STCheckZigzagLanding,
                                                    deadend,
                                                    stip_traversal_context_defense);
      assert(landing!=no_slice);
      link_to_branch(played,landing);
    }
  }

  TraceFunctionExit(__func__);
  TraceFunctionResultEnd();
}
Exemple #25
0
static void insert_promoter(slice_index si, stip_structure_traversal *st)
{
  slice_index const * const landing = st->param;

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

  {
    slice_index const proxy = alloc_proxy_slice();
    slice_index const prototype = alloc_fork_slice(STPawnToImitatorPromoter,proxy);
    assert(*landing!=no_slice);
    link_to_branch(proxy,*landing);
    promotion_insert_slices(si,st->context,&prototype,1);
  }

  TraceFunctionExit(__func__);
  TraceFunctionResultEnd();
}
Exemple #26
0
static void move_to_postkey(slice_index si, stip_structure_traversal *st)
{
  slice_index * const root_slice = st->param;

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

  stip_traverse_structure_children_pipe(si,st);

  if (*root_slice!=no_slice)
  {
    link_to_branch(si,*root_slice);
    *root_slice = si;
  }

  TraceFunctionExit(__func__);
  TraceFunctionResultEnd();
}
Exemple #27
0
/* Create a shallow copy of the visited fork slice
 * @param si visited slice
 * @param st structure representing the copying traversal
 */
static void copy_shallow(slice_index si, stip_structure_traversal *st)
{
  stip_deep_copies_type * const copies = st->param;

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

  assert((*copies)[si]==no_slice);
  (*copies)[si] = copy_slice(si);

  stip_traverse_structure_children_pipe(si,st);

  if (SLICE_NEXT1(si)!=no_slice)
    link_to_branch((*copies)[si],(*copies)[SLICE_NEXT1(si)]);

  TraceFunctionExit(__func__);
  TraceFunctionResultEnd();
}
Exemple #28
0
/* Add the copy of a slice into the set play branch
 * @param si slice index
 * @param st state of traversal
 */
static void copy_to_setplay(slice_index si, stip_structure_traversal *st)
{
  spin_off_state_type * const state = st->param;

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

  stip_traverse_structure_children_pipe(si,st);
  TraceValue("%u",state->spun_off[SLICE_NEXT1(si)]);
  TraceEOL();

  state->spun_off[si] = copy_slice(si);
  link_to_branch(state->spun_off[si],state->spun_off[SLICE_NEXT1(si)]);
  TraceValue("%u",state->spun_off[si]);
  TraceEOL();

  TraceFunctionExit(__func__);
  TraceFunctionResultEnd();
}
Exemple #29
0
static slice_index MakeSemireflexBranch(slice_index proxy_to_goal)
{
    slice_index result;

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

    {
        slice_index const branch = alloc_battle_branch(1,0);
        result = alloc_proxy_slice();
        link_to_branch(result,branch);
        battle_branch_insert_direct_end_of_branch_goal(branch,proxy_to_goal);
    }

    TraceFunctionExit(__func__);
    TraceFunctionResult("%u",result);
    TraceFunctionResultEnd();
    return result;
}
Exemple #30
0
/* Spin a STContraintSolver slice off a STContraintTester sliceto add it to the
 * root or set play branch
 * @param si identifies (non-root) slice
 * @param st address of structure representing traversal
 */
void constraint_tester_make_root(slice_index si, stip_structure_traversal *st)
{
  spin_off_state_type * const state = st->param;

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

  stip_traverse_structure_children_pipe(si,st);

  if (state->spun_off[SLICE_NEXT1(si)]!=no_slice)
  {
    state->spun_off[si] = alloc_constraint_solver_slice(stip_deep_copy(SLICE_NEXT2(si)));
    link_to_branch(state->spun_off[si],state->spun_off[SLICE_NEXT1(si)]);
  }

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

  TraceFunctionExit(__func__);
  TraceFunctionResultEnd();
}