/* Parse a move inversion * @param tok input token * @param start index of entry into solving machinery * @param proxy index of branch; no_slice if operator 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_move_inversion(char *tok, slice_index start, slice_index proxy, expression_type *type, unsigned int level) { TraceFunctionEntry(__func__); TraceFunctionParam("%s",tok); TraceFunctionParam("%u",start); TraceFunctionParam("%u",proxy); TraceFunctionParam("%u",level); TraceFunctionParamListEnd(); tok = ParseStructuredStip_operand(tok+1,start,proxy,type,level); { slice_index const operand = SLICE_NEXT1(proxy); if (tok!=0 && operand!=no_slice) { slice_index const prototype = alloc_move_inverter_slice(); slice_insertion_insert(proxy,&prototype,1); } } TraceFunctionExit(__func__); TraceFunctionResult("%s",tok); TraceFunctionResultEnd(); return tok; }
/* 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; }
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(); }
void insert_temporary_hacks(slice_index root_slice) { TraceFunctionEntry(__func__); TraceFunctionParam("%u",root_slice); TraceFunctionParamListEnd(); { slice_index const proxy = alloc_proxy_slice(); slice_index const entry_point = alloc_conditional_pipe(STTemporaryHackFork,proxy); slice_index const inverter = alloc_move_inverter_slice(); pipe_link(proxy,alloc_true_slice()); temporary_hack_mate_tester[Black] = make_mate_tester_fork(Black); temporary_hack_mate_tester[White] = make_mate_tester_fork(White); temporary_hack_exclusive_mating_move_counter[Black] = make_exclusive_mating_move_counter_fork(Black); temporary_hack_exclusive_mating_move_counter[White] = make_exclusive_mating_move_counter_fork(White); temporary_hack_brunner_check_defense_finder[Black] = make_brunner_check_defense_finder(Black); temporary_hack_brunner_check_defense_finder[White] = make_brunner_check_defense_finder(White); temporary_hack_ultra_mummer_length_measurer[Black] = make_ultra_mummer_length_measurer(Black); temporary_hack_ultra_mummer_length_measurer[White] = make_ultra_mummer_length_measurer(White); temporary_hack_move_legality_tester[Black] = make_move_legality_tester(Black); temporary_hack_move_legality_tester[White] = make_move_legality_tester(White); temporary_hack_king_capture_legality_tester[Black] = make_king_capture_legality_tester(Black); temporary_hack_king_capture_legality_tester[White] = make_king_capture_legality_tester(White); temporary_hack_cagecirce_noncapture_finder[Black] = make_cagecirce_noncapture_finder(Black); temporary_hack_cagecirce_noncapture_finder[White] = make_cagecirce_noncapture_finder(White); temporary_hack_circe_take_make_rebirth_squares_finder[Black] = make_circe_take_make_rebirth_squares_finder(Black); temporary_hack_circe_take_make_rebirth_squares_finder[White] = make_circe_take_make_rebirth_squares_finder(White); temporary_hack_castling_intermediate_move_legality_tester[Black] = make_castling_intermediate_move_legality_tester(Black); temporary_hack_castling_intermediate_move_legality_tester[White] = make_castling_intermediate_move_legality_tester(White); temporary_hack_opponent_moves_counter[Black] = make_opponent_moves_counter_fork(Black); temporary_hack_opponent_moves_counter[White] = make_opponent_moves_counter_fork(White); temporary_hack_back_home_finder[Black] = make_back_home_finder(Black); temporary_hack_back_home_finder[White] = make_back_home_finder(White); temporary_hack_suffocation_by_paralysis_finder[Black] = make_suffocation_by_paralysis_detector(Black); temporary_hack_suffocation_by_paralysis_finder[White] = make_suffocation_by_paralysis_detector(White); temporary_hack_move_generator[Black] = make_move_generator(Black); temporary_hack_move_generator[White] = make_move_generator(White); make_is_square_observed(Black); make_is_square_observed(White); temporary_hack_check_validator[Black] = make_check_validator(Black); temporary_hack_check_validator[White] = make_check_validator(White); temporary_hack_observation_validator[Black] = make_observation_validator(Black); temporary_hack_observation_validator[White] = make_observation_validator(White); temporary_hack_observer_validator[Black] = make_observer_validator(Black); temporary_hack_observer_validator[White] = make_observer_validator(White); temporary_hack_observation_geometry_validator[Black] = make_observation_geometry_validator(Black); temporary_hack_observation_geometry_validator[White] = make_observation_geometry_validator(White); temporary_hack_check_tester = make_check_tester(); slice_insertion_insert(root_slice,&entry_point,1); pipe_append(proxy,temporary_hack_mate_tester[White]); pipe_append(temporary_hack_mate_tester[White], temporary_hack_exclusive_mating_move_counter[White]); pipe_append(temporary_hack_exclusive_mating_move_counter[White], temporary_hack_brunner_check_defense_finder[White]); pipe_append(temporary_hack_brunner_check_defense_finder[White], temporary_hack_ultra_mummer_length_measurer[White]); pipe_append(temporary_hack_ultra_mummer_length_measurer[White], temporary_hack_move_legality_tester[White]); pipe_append(temporary_hack_move_legality_tester[White], temporary_hack_king_capture_legality_tester[White]); pipe_append(temporary_hack_king_capture_legality_tester[White], temporary_hack_cagecirce_noncapture_finder[White]); pipe_append(temporary_hack_cagecirce_noncapture_finder[White], temporary_hack_circe_take_make_rebirth_squares_finder[White]); pipe_append(temporary_hack_circe_take_make_rebirth_squares_finder[White], temporary_hack_castling_intermediate_move_legality_tester[White]); pipe_append(temporary_hack_castling_intermediate_move_legality_tester[White], temporary_hack_opponent_moves_counter[White]); pipe_append(temporary_hack_opponent_moves_counter[White], temporary_hack_back_home_finder[White]); pipe_append(temporary_hack_back_home_finder[White], temporary_hack_suffocation_by_paralysis_finder[White]); pipe_append(temporary_hack_suffocation_by_paralysis_finder[White], temporary_hack_move_generator[White]); pipe_append(temporary_hack_move_generator[White], temporary_hack_is_square_observed_specific[White]); pipe_append(temporary_hack_is_square_observed_specific[White], temporary_hack_is_square_observed[White]); pipe_append(temporary_hack_is_square_observed[White], temporary_hack_check_validator[White]); pipe_append(temporary_hack_check_validator[White], temporary_hack_observation_validator[White]); pipe_append(temporary_hack_observation_validator[White], temporary_hack_observation_geometry_validator[White]); pipe_append(temporary_hack_observation_geometry_validator[White], temporary_hack_observer_validator[White]); pipe_append(temporary_hack_observer_validator[White], inverter); pipe_append(inverter,temporary_hack_mate_tester[Black]); pipe_append(temporary_hack_mate_tester[Black], temporary_hack_exclusive_mating_move_counter[Black]); pipe_append(temporary_hack_exclusive_mating_move_counter[Black], temporary_hack_brunner_check_defense_finder[Black]); pipe_append(temporary_hack_brunner_check_defense_finder[Black], temporary_hack_ultra_mummer_length_measurer[Black]); pipe_append(temporary_hack_ultra_mummer_length_measurer[Black], temporary_hack_move_legality_tester[Black]); pipe_append(temporary_hack_move_legality_tester[Black], temporary_hack_king_capture_legality_tester[Black]); pipe_append(temporary_hack_king_capture_legality_tester[Black], temporary_hack_cagecirce_noncapture_finder[Black]); pipe_append(temporary_hack_cagecirce_noncapture_finder[Black], temporary_hack_circe_take_make_rebirth_squares_finder[Black]); pipe_append(temporary_hack_circe_take_make_rebirth_squares_finder[Black], temporary_hack_castling_intermediate_move_legality_tester[Black]); pipe_append(temporary_hack_castling_intermediate_move_legality_tester[Black], temporary_hack_opponent_moves_counter[Black]); pipe_append(temporary_hack_opponent_moves_counter[Black], temporary_hack_back_home_finder[Black]); pipe_append(temporary_hack_back_home_finder[Black], temporary_hack_suffocation_by_paralysis_finder[Black]); pipe_append(temporary_hack_suffocation_by_paralysis_finder[Black], temporary_hack_move_generator[Black]); pipe_append(temporary_hack_move_generator[Black], temporary_hack_is_square_observed_specific[Black]); pipe_append(temporary_hack_is_square_observed_specific[Black], temporary_hack_is_square_observed[Black]); pipe_append(temporary_hack_is_square_observed[Black], temporary_hack_check_validator[Black]); pipe_append(temporary_hack_check_validator[Black], temporary_hack_observation_validator[Black]); pipe_append(temporary_hack_observation_validator[Black], temporary_hack_observation_geometry_validator[Black]); pipe_append(temporary_hack_observation_geometry_validator[Black], temporary_hack_observer_validator[Black]); pipe_append(temporary_hack_observer_validator[Black], temporary_hack_check_tester); if (SLICE_STARTER(root_slice)==Black) pipe_append(proxy,alloc_move_inverter_slice()); } TraceFunctionExit(__func__); TraceFunctionResultEnd(); }