/* 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 marscirce_move_to_rebirth_square_solve(slice_index si) { numecoup const curr = CURRMOVE_OF_PLY(nbply); move_generation_elmt * const move_gen_top = move_generation_stack+curr; numecoup const id = move_gen_top->id; square const sq_capture = move_gen_top->capture; TraceFunctionEntry(__func__); TraceFunctionParam("%u",si); TraceFunctionParamListEnd(); if (marscirce_rebirth_square[id]==initsquare /* marscirce_rebirth_square isn't set when castlings are generated */ || (min_castling<=sq_capture && sq_capture<=max_castling)) { move_effect_journal_do_null_effect(); pipe_solve_delegate(si); } else { square const sq_departure = move_gen_top->departure; move_effect_journal_do_piece_movement(move_effect_reason_phantom_movement, sq_departure,marscirce_rebirth_square[id]); move_gen_top->departure = marscirce_rebirth_square[id]; pipe_solve_delegate(si); move_gen_top->departure = sq_departure; } TraceFunctionExit(__func__); TraceFunctionResultEnd(); }
/* 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 singlebox_type2_latent_pawn_promoter_solve(slice_index si) { TraceFunctionEntry(__func__); TraceFunctionParam("%u",si); TraceFunctionParamListEnd(); if (post_move_iteration_id[nbply]!=prev_post_move_iteration_id_promotion[nbply]) init_latent_pawn_promotion(); if (singlebox_type2_latent_pawn_promotions[nbply].promotion.promotee==Empty) pipe_solve_delegate(si); else { move_effect_journal_do_walk_change(move_effect_reason_singlebox_promotion, singlebox_type2_latent_pawn_promotions[nbply].where, singlebox_type2_latent_pawn_promotions[nbply].promotion.promotee); pipe_solve_delegate(si); if (!post_move_iteration_locked[nbply]) { advance_latent_pawn_promotion(); if (singlebox_type2_latent_pawn_promotions[nbply].promotion.promotee!=Empty) lock_post_move_iterations(); } } prev_post_move_iteration_id_promotion[nbply] = post_move_iteration_id[nbply]; TraceFunctionExit(__func__); TraceFunctionResultEnd(); }
/* 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 exclusive_chess_legality_tester_solve(slice_index si) { TraceFunctionEntry(__func__); TraceFunctionParam("%u",si); TraceFunctionParamListEnd(); if ((table_length(exclusive_chess_undecidable_continuations[parent_ply[nbply]]) +exclusive_chess_nr_continuations_reaching_goal[parent_ply[nbply]]) >1) { if (is_current_move_in_table(exclusive_chess_undecidable_continuations[parent_ply[nbply]])) solve_result = this_move_is_illegal; else switch (conditional_pipe_solve_delegate(temporary_hack_mate_tester[advers(trait[nbply])])) { case this_move_is_illegal: solve_result = this_move_is_illegal; break; case previous_move_has_not_solved: pipe_solve_delegate(si); break; default: solve_result = previous_move_has_solved; break; } } else pipe_solve_delegate(si); TraceFunctionExit(__func__); TraceFunctionResultEnd(); }
/* 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_enforcer_solve(slice_index si) { ply const threats_ply = parent_ply[nbply]; stip_length_type const len_threat = threat_lengths[threats_ply]; TraceFunctionEntry(__func__); TraceFunctionParam("%u",si); TraceFunctionParamListEnd(); TraceValue("%u",len_threat); TraceEOL(); if (len_threat<=slack_length) /* the move has something stronger than threats (typically, it * delivers check) */ pipe_solve_delegate(si); else if (len_threat<=MOVE_HAS_SOLVED_LENGTH()) { /* there are >=1 threats - don't report variations shorter than * the threats or variations that don't refute any threat */ table const threats_table = threats[threats_ply]; stip_length_type len_test_threats; nr_threats_to_be_confirmed = table_length(threats_table); len_test_threats = testing_pipe_solve_delegate(si,len_threat); if (len_test_threats>len_threat) /* variation is longer than threat */ pipe_solve_delegate(si); else if (len_test_threats>len_threat-2 && nr_threats_to_be_confirmed>0) /* variation has same length as the threat(s), but it has * defeated at least one threat */ pipe_solve_delegate(si); else /* variation is shorter than threat */ solve_result = len_test_threats; } else /* zugzwang, or we haven't looked for threats yet */ pipe_solve_delegate(si); TraceFunctionExit(__func__); TraceFunctionResultEnd(); }
/* 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 singlebox_type2_latent_pawn_selector_solve(slice_index si) { TraceFunctionEntry(__func__); TraceFunctionParam("%u",si); TraceFunctionParamListEnd(); if (post_move_iteration_id[nbply]!=prev_post_move_iteration_id_selection[nbply]) init_latent_pawn_selection(SLICE_STARTER(si)); pipe_solve_delegate(si); if (singlebox_type2_latent_pawn_promotions[nbply].where!=initsquare) { if (!post_move_iteration_locked[nbply]) { advance_latent_pawn_selection(SLICE_STARTER(si)); if (singlebox_type2_latent_pawn_promotions[nbply].where!=initsquare) lock_post_move_iterations(); } } prev_post_move_iteration_id_selection[nbply] = post_move_iteration_id[nbply]; TraceFunctionExit(__func__); TraceFunctionResultEnd(); }
static void by_knight(slice_index si, unsigned int index_of_checker, square const check_from) { int const diff = being_solved.king_square[Black]-check_from; int const dir = CheckDir[Knight][diff]; TraceFunctionEntry(__func__); TraceFunctionParam("%u",index_of_checker); TraceSquare(check_from); TraceFunctionParamListEnd(); if (dir!=0 && intelligent_reserve_white_officer_moves_from_to_checking(white[index_of_checker].diagram_square, Knight, check_from)) { occupy_square(check_from,Knight,white[index_of_checker].flags); init_disturb_mate_dir(check_from,being_solved.king_square[Black]-check_from); pipe_solve_delegate(si); fini_disturb_mate_dir(); intelligent_unreserve(); } TraceFunctionExit(__func__); TraceFunctionResultEnd(); }
static void by_rider(slice_index si, unsigned int index_of_checker, square const check_from) { piece_walk_type const checker_type = white[index_of_checker].type; Flags const checker_flags = white[index_of_checker].flags; int const diff = being_solved.king_square[Black]-check_from; int const dir = CheckDir[checker_type][diff]; TraceFunctionEntry(__func__); TraceFunctionParam("%u",index_of_checker); TraceSquare(check_from); TraceFunctionParamListEnd(); if (dir!=0 && intelligent_reserve_white_officer_moves_from_to_checking(white[index_of_checker].diagram_square, checker_type, check_from)) { occupy_square(check_from,checker_type,checker_flags); remember_mating_line(checker_type,check_from,+1); pipe_solve_delegate(si); remember_mating_line(checker_type,check_from,-1); intelligent_unreserve(); } TraceFunctionExit(__func__); TraceFunctionResultEnd(); }
static void by_unpromoted_pawn(slice_index si, unsigned int index_of_checker, square const check_from) { square const checker_from = white[index_of_checker].diagram_square; Flags const checker_flags = white[index_of_checker].flags; SquareFlags const prom_square = BIT(WhPromSq)|BIT(BlPromSq); TraceFunctionEntry(__func__); TraceFunctionParam("%u",index_of_checker); TraceSquare(check_from); TraceFunctionParamListEnd(); if (!TSTFLAGMASK(sq_spec[check_from],prom_square) && GuardDir[Pawn-Pawn][check_from].dir==guard_dir_check_uninterceptable && intelligent_reserve_white_pawn_moves_from_to_checking(checker_from,check_from)) { occupy_square(check_from,Pawn,checker_flags); init_disturb_mate_dir(check_from,being_solved.king_square[Black]-check_from); pipe_solve_delegate(si); fini_disturb_mate_dir(); empty_square(check_from); intelligent_unreserve(); } TraceFunctionExit(__func__); TraceFunctionResultEnd(); }
/* * 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(); }
/* 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 en_passant_redo_multistep(slice_index si) { TraceFunctionEntry(__func__); TraceFunctionParam("%u",si); TraceFunctionParamListEnd(); assert(en_passant_nr_retro_squares>2); move_effect_journal_do_no_piece_removal(); { unsigned int i; move_effect_journal_do_piece_movement(move_effect_reason_moving_piece_movement, en_passant_retro_squares[0], en_passant_retro_squares[en_passant_nr_retro_squares-1]); for (i = 1; i<en_passant_nr_retro_squares-1; ++i) en_passant_remember_multistep_over(en_passant_retro_squares[i]); } pipe_solve_delegate(si); TraceFunctionExit(__func__); TraceFunctionResultEnd(); }
/* 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(); }
void hashtable_dimensioner_solve(slice_index si) { if (dimensionHashtable()) pipe_solve_delegate(si); else fputs("Couldn't allocate the requested amount of memory\n",stdout); }
/* Delegate finding a solution to the next1 slice, gradually increasing * the number of allowed half-moves * @param si slice index of slice being solved * @param n maximum number of half moves until end state has to be reached * @param n_min minimum number of half-moves to try * @return length of solution found and written, i.e.: * previous_move_is_illegal the move just played or being played is illegal * <=n length of shortest solution found * n+2 no solution found */ static stip_length_type delegate_solve(slice_index si, stip_length_type n, stip_length_type n_min) { stip_length_type result = n+2; stip_length_type const save_solve_nr_remaining = MOVE_HAS_SOLVED_LENGTH(); TraceFunctionEntry(__func__); TraceFunctionParam("%u",si); TraceFunctionParam("%u",n_min); TraceFunctionParamListEnd(); for (solve_nr_remaining = n_min+(n-n_min)%2; solve_nr_remaining<=n; solve_nr_remaining += 2) { pipe_solve_delegate(si); result = solve_result; if (result<=MOVE_HAS_SOLVED_LENGTH()) break; } solve_nr_remaining = save_solve_nr_remaining; TraceFunctionExit(__func__); TraceFunctionResult("%u",result); TraceFunctionResultEnd(); return result; }
/* 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 opponent_moves_counter_solve(slice_index si) { numecoup const move_id = move_generation_stack[CURRMOVE_OF_PLY(nbply)].id; TraceFunctionEntry(__func__); TraceFunctionParam("%u",si); TraceFunctionParamListEnd(); legal_move_count_init(UINT_MAX); pipe_solve_delegate(si); if (solve_result==this_move_is_illegal) /* Defenses leading to self check get a big count. * But still make sure that we can correctly compute the difference of two * counts. */ opponent_moves_few_moves_prioriser_table[move_id] = INT_MAX/2; else opponent_moves_few_moves_prioriser_table[move_id] = legal_move_counter_count[nbply]; legal_move_count_fini(); solve_result = MOVE_HAS_SOLVED_LENGTH(); TraceFunctionExit(__func__); TraceFunctionResultEnd(); }
/* 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(); }
/* 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 orthodox_mating_king_contact_generator_solve(slice_index si) { Side const moving = SLICE_STARTER(si); Side const mated = advers(moving); square const sq_mated_king = being_solved.king_square[mated]; TraceFunctionEntry(__func__); TraceFunctionParam("%u",si); TraceFunctionParamListEnd(); assert(solve_nr_remaining==slack_length+1); curr_generation->departure = being_solved.king_square[moving]; if (curr_generation->departure!=sq_mated_king) { vec_index_type k; for (k = vec_queen_start; k<=vec_queen_end; k++) { curr_generation->arrival = curr_generation->departure+vec[k]; if ((is_square_empty(curr_generation->arrival) || TSTFLAG(being_solved.spec[curr_generation->arrival],mated)) && move_diff_code[abs(sq_mated_king-curr_generation->arrival)]<=1+1) push_move(); } } pipe_solve_delegate(si); TraceFunctionExit(__func__); TraceFunctionResultEnd(); }
/* verify that the proof or A=>B goal is unique * @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 proof_verify_unique_goal_solve(slice_index si) { if (find_unique_goal(si).type==no_goal) output_plaintext_verifie_message(MultipleGoalsWithProofGameNotAcceptable); else pipe_solve_delegate(si); }
/* 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 half_neutral_recolorer_solve(slice_index si) { TraceFunctionEntry(__func__); TraceFunctionParam("%u",si); TraceFunctionParamListEnd(); { move_effect_journal_index_type const base = move_effect_journal_base[nbply]; move_effect_journal_index_type const movement = base+move_effect_journal_index_offset_movement; square const sq_arrival = move_effect_journal[movement].u.piece_movement.to; Flags const movingspec = move_effect_journal[movement].u.piece_movement.movingspec; PieceIdType const moving_id = GetPieceId(movingspec); square const pos = move_effect_journal_follow_piece_through_other_effects(nbply, moving_id, sq_arrival); if (TSTFLAG(movingspec,HalfNeutral)) { if (is_piece_neutral(being_solved.spec[pos])) do_deneutralisation(pos,SLICE_STARTER(si)); else do_neutralisation(pos); } } pipe_solve_delegate(si); TraceFunctionExit(__func__); TraceFunctionResultEnd(); }
/* 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 haunted_chess_ghost_rememberer_solve(slice_index si) { move_effect_journal_index_type const top = move_effect_journal_base[nbply]; move_effect_journal_index_type const capture = top+move_effect_journal_index_offset_capture; TraceFunctionEntry(__func__); TraceFunctionParam("%u",si); TraceFunctionParamListEnd(); if (move_effect_journal[capture].type!=move_effect_no_piece_removal) { square const sq_capture = move_generation_stack[CURRMOVE_OF_PLY(nbply)].capture; underworld_index_type const preempted_idx = underworld_find_last(sq_capture); if (preempted_idx!=ghost_not_found) move_effect_journal_do_forget_ghost(preempted_idx); move_effect_journal_do_remember_ghost(); } pipe_solve_delegate(si); TraceFunctionExit(__func__); TraceFunctionResultEnd(); }
/* 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 haunted_chess_ghost_summoner_solve(slice_index si) { underworld_index_type idx_ghost = nr_ghosts; TraceFunctionEntry(__func__); TraceFunctionParam("%u",si); TraceFunctionParamListEnd(); while (idx_ghost>0) { --idx_ghost; if (is_square_empty(underworld[idx_ghost].on)) { move_effect_journal_do_piece_readdition(move_effect_reason_summon_ghost, underworld[idx_ghost].on, underworld[idx_ghost].walk, underworld[idx_ghost].flags, no_side); move_effect_journal_do_forget_ghost(idx_ghost); } } pipe_solve_delegate(si); TraceFunctionExit(__func__); TraceFunctionResultEnd(); }
/* 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 strict_sat_updater_solve(slice_index si) { move_effect_journal_index_type const save_horizon = king_square_horizon; TraceFunctionEntry(__func__); TraceFunctionParam("%u",si); TraceFunctionParamListEnd(); assert(strictsat_updating==nr_sides); update_king_squares(); if (!StrictSAT[White]) { strictsat_updating = White; if (is_in_check(White)) do_strict_sat_adjustment(White); } if (!StrictSAT[Black]) { strictsat_updating = Black; if (is_in_check(Black)) do_strict_sat_adjustment(Black); } strictsat_updating = nr_sides; pipe_solve_delegate(si); king_square_horizon = save_horizon; TraceFunctionExit(__func__); TraceFunctionResultEnd(); }
/* 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 find_by_increasing_length_solve(slice_index si) { stip_length_type result_intermediate = MOVE_HAS_NOT_SOLVED_LENGTH(); stip_length_type const save_solve_nr_remaining = MOVE_HAS_SOLVED_LENGTH(); TraceFunctionEntry(__func__); TraceFunctionParam("%u",si); TraceFunctionParamListEnd(); for (solve_nr_remaining = SLICE_U(si).branch.min_length; solve_nr_remaining<=save_solve_nr_remaining; solve_nr_remaining += 2) { pipe_solve_delegate(si); if (solve_result==MOVE_HAS_SOLVED_LENGTH() && solve_nr_remaining<result_intermediate) result_intermediate = solve_nr_remaining; } solve_nr_remaining = save_solve_nr_remaining; solve_result = result_intermediate; TraceFunctionExit(__func__); TraceFunctionResultEnd(); }
/* 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 retro_start_retro_move_ply(slice_index si) { TraceFunctionEntry(__func__); TraceFunctionParam("%u",si); TraceFunctionParamListEnd(); /* Make sure that trait is the opposite of the first move (or there * will be no e.p. capture). */ assert(slices[si].starter!=no_side); nextply(advers(slices[si].starter)); assert(nbply==ply_retro_move); { /* TODO let Mars Circe or SingleBox Type 3 add slices here that do this */ unsigned int i; for (i = 0; i!=move_effect_journal_index_offset_capture; ++i) move_effect_journal_do_null_effect(); } pipe_solve_delegate(si); undo_move_effects(); finply(); TraceFunctionExit(__func__); TraceFunctionResultEnd(); }
/* 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(); }
/* Determine whether a square is observed be the side at the move according to * Vaulting Kings * @param si identifies next slice * @note sets observation_validation_result */ void vaulting_king_is_square_observed(slice_index si) { Side const side_observing = trait[nbply]; TraceFunctionEntry(__func__); TraceFunctionParam("%u",si); TraceFunctionParamListEnd(); if (being_solved.king_square[side_observing]==initsquare) pipe_solve_delegate(si); else { is_king_vaulting[nbply] = dont_know; pipe_solve_delegate(si); } TraceFunctionExit(__func__); TraceFunctionResultEnd(); }
/* 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 goal_any_reached_tester_solve(slice_index si) { TraceFunctionEntry(__func__); TraceFunctionParam("%u",si); TraceFunctionParamListEnd(); pipe_solve_delegate(si); TraceFunctionExit(__func__); TraceFunctionResultEnd(); }
/* 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 republican_king_placer_solve(slice_index si) { move_effect_journal_index_type const save_horizon = king_square_horizon; TraceFunctionEntry(__func__); TraceFunctionParam("%u",si); TraceFunctionParamListEnd(); update_king_squares(); if (being_solved.king_square[advers(SLICE_STARTER(si))]==initsquare) { determine_king_placement(SLICE_STARTER(si)); if (king_placement[nbply]==king_not_placed) { pipe_solve_delegate(si); king_placement[nbply] = to_be_initialised; } else { place_king(SLICE_STARTER(si)); pipe_solve_delegate(si); if (!post_move_iteration_locked[nbply]) { is_mate_square_dirty[nbply] = true; lock_post_move_iterations(); } } prev_post_move_iteration_id[nbply] = post_move_iteration_id[nbply]; } else pipe_solve_delegate(si); king_square_horizon = save_horizon; TraceFunctionExit(__func__); TraceFunctionResultEnd(); }
void command_line_options_parser_solve(slice_index si) { int const argc = SLICE_U(si).command_line_options_parser.argc; char **argv = SLICE_U(si).command_line_options_parser.argv; int const idx_end_of_options = parseCommandlineOptions(argc,argv); char const *filename = idx_end_of_options<argc ? argv[idx_end_of_options] : ""; slice_index const opener = input_plaintext_alloc_opener(filename); slice_insertion_insert(si,&opener,1); pipe_solve_delegate(si); }
/* 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 reverse_einstein_moving_adjuster_solve(slice_index si) { TraceFunctionEntry(__func__); TraceFunctionParam("%u",si); TraceFunctionParamListEnd(); adjust(); pipe_solve_delegate(si); TraceFunctionExit(__func__); TraceFunctionResultEnd(); }
/* Instrument the solving machinery with option maxsolutions * @param si identifies the slice where to start instrumenting */ void maxsolutions_solving_instrumenter_solve(slice_index si) { TraceFunctionEntry(__func__); TraceFunctionParamListEnd(); instrument_solvers(si); pipe_solve_delegate(si); TraceFunctionExit(__func__); TraceFunctionResultEnd(); }