Beispiel #1
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 continuation_solver_solve(slice_index si)
{
  TraceFunctionEntry(__func__);
  TraceFunctionParam("%u",si);
  TraceFunctionParamListEnd();

  fork_solve_delegate(si);

  if (move_has_solved())
  {
#if !defined(NDEBUG)
    stip_length_type const test_result = solve_result;
#endif
    stip_length_type const save_solve_nr_remaining = solve_nr_remaining;

    if (solve_nr_remaining>solve_result)
      solve_nr_remaining = solve_result;
    pipe_solve_delegate(si);
    solve_nr_remaining = save_solve_nr_remaining;

    assert(solve_result==test_result);
  }

  TraceFunctionExit(__func__);
  TraceFunctionResultEnd();
}
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 maxsolutions_counter_solve(slice_index si)
{
  TraceFunctionEntry(__func__);
  TraceFunctionParam("%u",si);
  TraceFunctionParamListEnd();

  pipe_solve_delegate(si);

  if (move_has_solved())
    increase_nr_found_solutions();

  TraceFunctionExit(__func__);
  TraceFunctionResultEnd();
}
Beispiel #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 threat_collector_solve(slice_index si)
{
  TraceFunctionEntry(__func__);
  TraceFunctionParam("%u",si);
  TraceFunctionParamListEnd();

  pipe_solve_delegate(si);

  if (move_has_solved())
    append_to_table(threats[parent_ply[parent_ply[nbply]]]);

  TraceFunctionExit(__func__);
  TraceFunctionResultEnd();
}
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 killer_attack_collector_solve(slice_index si)
{
  TraceFunctionEntry(__func__);
  TraceFunctionParam("%u",si);
  TraceFunctionParamListEnd();

  pipe_solve_delegate(si);

  if (move_has_solved())
    remember_killer_move();

  TraceFunctionExit(__func__);
  TraceFunctionResultEnd();
}
Beispiel #5
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 threat_defeated_tester_solve(slice_index si)
{
  ply const threats_ply = parent_ply[parent_ply[nbply]];

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

  pipe_solve_delegate(si);

  /* we are not interested in whether threats are refuted when we are looking
   * for short continuations to defenses
   */
  if (solve_nr_remaining>=threat_lengths[threats_ply]-2)
  {
    if (is_current_move_in_table(threats[threats_ply]))
    {
      if (move_has_solved())
      {
        --nr_threats_to_be_confirmed;
        if (nr_threats_to_be_confirmed>0)
          /* threats tried so far still work (perhaps shorter than
           * before the current defense), but we haven't tried all
           * threats yet -> don't stop the iteration over the
           * attacking moves
           */
          solve_result = MOVE_HAS_NOT_SOLVED_LENGTH();
      }
      else if (solve_nr_remaining==threat_lengths[threats_ply]-1)
        /* we have found a defeated threat -> stop the iteration */
        solve_result = MOVE_HAS_SOLVED_LENGTH();
    }
    else
      /* not a threat -> don't stop the iteration */
      solve_result = MOVE_HAS_NOT_SOLVED_LENGTH();
  }

  TraceFunctionExit(__func__);
  TraceFunctionResultEnd();
}