Beispiel #1
0
static void HandleAddedPiece(square s, void *param)
{
    piece_addition_settings * const settings = param;

    if (!is_square_empty(s))
    {
        if (settings->type==piece_addition_initial)
        {
            WriteSquare(&output_plaintext_engine,stdout,s);
            output_plaintext_message(OverwritePiece);

            underworld_make_space(nr_ghosts);
            underworld[nr_ghosts-1].walk = get_walk_of_piece_on_square(s);
            underworld[nr_ghosts-1].flags = being_solved.spec[s];
            underworld[nr_ghosts-1].on = s;
        }
        else
        {
            move_effect_journal_do_circe_volcanic_remember(move_effect_reason_diagram_setup,
                    s);
            move_effect_journal_do_piece_removal(move_effect_reason_diagram_setup,
                                                 s);
        }
    }

    if (settings->type==piece_addition_twinning)
        move_effect_journal_do_piece_creation(move_effect_reason_diagram_setup,
                                              s,settings->walk,
                                              settings->spec,
                                              no_side);
    else
        occupy_square(s,settings->walk,settings->spec);
}
Beispiel #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 imitator_pawn_promoter_solve(slice_index si)
{
  TraceFunctionEntry(__func__);
  TraceFunctionParam("%u",si);
  TraceFunctionParamListEnd();

  {
    square sq_arrival;
    Side as_side;

    find_potential_promotion_square(promotion_horizon[nbply],&sq_arrival,&as_side);

    assert(stack_pointer<stack_size);

    if (post_move_iteration_id[nbply]!=prev_post_move_iteration_id[stack_pointer])
      promotion_into_imitator[stack_pointer] = is_square_occupied_by_promotable_pawn(sq_arrival,as_side);

    TraceValue("%u",post_move_iteration_id[nbply]);
    TraceValue("%u",prev_post_move_iteration_id[stack_pointer]);
    TraceValue("%u\n",promotion_into_imitator[stack_pointer]);

    if (promotion_into_imitator[stack_pointer])
    {
      move_effect_journal_index_type const save_horizon = promotion_horizon[nbply];

      promotion_horizon[nbply] = move_effect_journal_base[nbply+1];

      move_effect_journal_do_piece_removal(move_effect_reason_pawn_promotion,
                                           sq_arrival);
      move_effect_journal_do_imitator_addition(move_effect_reason_pawn_promotion,
                                               sq_arrival);

      ++stack_pointer;
      fork_solve_delegate(si);
      --stack_pointer;

      promotion_horizon[nbply] = save_horizon;

      TraceValue("%u\n",post_move_iteration_locked[nbply]);
      if (!post_move_iteration_locked[nbply])
      {
        promotion_into_imitator[stack_pointer] = false;
        lock_post_move_iterations();
      }
    }
    else
    {
      ++stack_pointer;
      pipe_solve_delegate(si);
      --stack_pointer;
    }

    prev_post_move_iteration_id[stack_pointer] = post_move_iteration_id[nbply];
  }

  TraceFunctionExit(__func__);
  TraceFunctionResultEnd();
}
Beispiel #3
0
static void HandleAddedPiece(square s, void *param)
{
  piece_addition_settings * const settings = param;

  if (!is_square_empty(s))
  {
    move_effect_journal_do_circe_volcanic_remember(move_effect_reason_diagram_setup,s);
    move_effect_journal_do_piece_removal(move_effect_reason_diagram_setup,s);
  }

  move_effect_journal_do_piece_creation(move_effect_reason_diagram_setup,
                                        s,settings->walk,
                                        settings->spec,
                                        no_side);
}
Beispiel #4
0
/* Try to solve in solve_nr_remaining half-moves.
 * @param si slice index
 * @note assigns solve_result the length of solution found and written, i.e.:
 *            previous_move_is_illegal the move just played is illegal
 *            this_move_is_illegal     the move being played is illegal
 *            immobility_on_next_move  the moves just played led to an
 *                                     unintended immobility on the next move
 *            <=n+1 length of shortest solution found (n+1 only if in next
 *                                     branch)
 *            n+2 no solution found in this branch
 *            n+3 no solution found in next branch
 *            (with n denominating solve_nr_remaining)
 */
void circe_assassin_assassinate_solve(slice_index si)
{
  circe_rebirth_context_elmt_type const * const context = &circe_rebirth_context_stack[circe_rebirth_context_stack_pointer];
  square const sq_rebirth = context->rebirth_square;
  Flags const mask = BIT(SLICE_STARTER(si))|BIT(Royal);

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

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

  TraceFunctionExit(__func__);
  TraceFunctionResultEnd();
}