예제 #1
0
파일: mummer.c 프로젝트: Die9teWoge/popeye
/* 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 mummer_orchestrator_solve(slice_index si)
{
  ply const save_nbply = nbply;

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

  mum_length[parent_ply[nbply]] = INT_MIN;
  reset_accepted_moves(nbply);

  copyply();
  move_generator_invert_move_order(nbply);
  fork_solve_delegate(si);
  finply();

  /* in some very obscure situations (cf. bug #142), we would continue with
   * e.g. knight promotion if queen promotion was played while measuring lengths
   */
  ++post_move_iteration_id[nbply];

  nbply = save_nbply;
  SET_CURRMOVE(nbply,last_candidate[nbply]);

  pipe_solve_delegate(si);

  TraceFunctionExit(__func__);
  TraceFunctionResultEnd();
}
예제 #2
0
static void remove_illegal_moves(void)
{
  numecoup curr = MOVEBASE_OF_PLY(nbply)+1;
  numecoup new_top = MOVEBASE_OF_PLY(nbply);

  TraceFunctionEntry(__func__);
  TraceFunctionParamListEnd();

  while (curr<=CURRMOVE_OF_PLY(nbply))
    curr = remove_illegal_moves_by_same_piece(curr,&new_top);

  SET_CURRMOVE(nbply,new_top);

  TraceFunctionExit(__func__);
  TraceFunctionResultEnd();
}
예제 #3
0
/* Only keep generated non-captures that fulfill some criterion; captures are all kept
 * @param start identifies last move on stack that the criterion will not be applied to
 * @param criterion to be fulfilled by moves kept
 */
void move_generator_filter_noncaptures(numecoup start,
                                       move_filter_criterion_type criterion)
{
  numecoup i;
  numecoup new_top = start;

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

  for (i = start+1; i<=CURRMOVE_OF_PLY(nbply); ++i)
    if (!is_square_empty(move_generation_stack[i].capture) || (*criterion)(i))
    {
      ++new_top;
      move_generation_stack[new_top] = move_generation_stack[i];
    }

  SET_CURRMOVE(nbply,new_top);

  TraceFunctionExit(__func__);
  TraceFunctionResultEnd();
}
예제 #4
0
파일: ply.c 프로젝트: thomas-maeder/popeye
/* resset the ply module */
void ply_reset(void)
{
  SET_CURRMOVE(nbply,nil_coup);
}