static numecoup remove_illegal_moves_by_same_mao(numecoup curr, numecoup *new_top) { square const sq_departure = move_generation_stack[curr].departure; TraceFunctionEntry(__func__); TraceValue("%u",curr); TraceSquare(sq_departure); TraceFunctionParamListEnd(); while (curr<=CURRMOVE_OF_PLY(nbply) && move_generation_stack[curr].departure==sq_departure) { square const sq_arrival = move_generation_stack[curr].arrival; square const sq_hurdle = hoppper_moves_auxiliary[move_generation_stack[curr].id].sq_hurdle; if (are_all_imitator_arrivals_empty(sq_departure,sq_hurdle) && are_all_imitator_arrivals_empty(sq_departure,sq_arrival)) { ++*new_top; move_generation_stack[*new_top] = move_generation_stack[curr]; } ++curr; } TraceFunctionExit(__func__); TraceFunctionResult("%u",curr); TraceFunctionResultEnd(); return curr; }
static numecoup remove_illegal_moves_by_same_rider_on_line(numecoup i, numvec diff, numecoup *new_top) { square const sq_departure = move_generation_stack[i].departure; square sq_next_arrival = sq_departure+diff; while (i<=CURRMOVE_OF_PLY(nbply) && move_generation_stack[i].departure==sq_departure && move_generation_stack[i].arrival==sq_next_arrival) if (are_all_imitator_arrivals_empty(sq_departure,sq_next_arrival)) { ++*new_top; move_generation_stack[*new_top] = move_generation_stack[i]; ++i; sq_next_arrival += diff; } else { i = skip_over_remainder_of_line(i,sq_departure,sq_next_arrival,diff); break; } return i; }
static boolean avoid_observing_if_imitator_blocked_angle_hopper(angle_t angle) { boolean result; square const sq_observer = move_generation_stack[CURRMOVE_OF_PLY(nbply)].departure; square const sq_landing = move_generation_stack[CURRMOVE_OF_PLY(nbply)].arrival; piece_walk_type const p = get_walk_of_piece_on_square(sq_observer); Flags const flags = being_solved.spec[sq_observer]; vec_index_type const vec_index_departure_hurdle = 2*interceptable_observation[observation_context].vector_index1; numvec const vec_departure_hurdle1 = -angle_vectors[angle][vec_index_departure_hurdle]; numvec const vec_departure_hurdle2 = -angle_vectors[angle][vec_index_departure_hurdle-1]; square const sq_hurdle = sq_landing+vec[interceptable_observation[observation_context].vector_index1]; numvec const diff_observer_hurdle = sq_hurdle-sq_observer; int const nr_steps1 = abs(diff_observer_hurdle/vec_departure_hurdle1); int const nr_steps2 = abs(diff_observer_hurdle/vec_departure_hurdle2); numvec step; if (nr_steps1==0) step = vec_departure_hurdle2; else if (nr_steps2==0) step = vec_departure_hurdle1; else step = nr_steps1<nr_steps2 ? vec_departure_hurdle1 : vec_departure_hurdle2; empty_square(sq_observer); result = (have_all_imitators_hurdle(diff_observer_hurdle) && are_all_imitator_lines_clear(step,step,diff_observer_hurdle) && are_all_imitator_arrivals_empty(sq_observer,sq_landing)); occupy_square(sq_observer,p,flags); return result; }
static boolean avoid_observing_if_imitator_blocked_chinese_leaper(void) { boolean result; square const sq_observer = move_generation_stack[CURRMOVE_OF_PLY(nbply)].departure; square const sq_landing = move_generation_stack[CURRMOVE_OF_PLY(nbply)].arrival; piece_walk_type const p = get_walk_of_piece_on_square(sq_observer); Flags const flags = being_solved.spec[sq_observer]; numvec const vec_pass_target = vec[interceptable_observation[observation_context].vector_index1]; square const sq_pass = sq_landing+vec_pass_target; empty_square(sq_observer); result = (are_all_imitator_arrivals_empty(sq_observer,sq_pass) && are_all_imitator_arrivals_empty(sq_observer,sq_landing)); occupy_square(sq_observer,p,flags); return result; }
static boolean avoid_observing_if_imitator_blocked_nonstop_equihopper(void) { boolean result; square const sq_observer = move_generation_stack[CURRMOVE_OF_PLY(nbply)].departure; square const sq_landing = move_generation_stack[CURRMOVE_OF_PLY(nbply)].arrival; piece_walk_type const p = get_walk_of_piece_on_square(sq_observer); Flags const flags = being_solved.spec[sq_observer]; numvec const diff_hurdle = (sq_landing-sq_observer)/2; empty_square(sq_observer); result = (have_all_imitators_hurdle(diff_hurdle) && are_all_imitator_arrivals_empty(sq_observer,sq_landing)); occupy_square(sq_observer,p,flags); return result; }
static numecoup remove_illegal_moves_by_same_king(numecoup curr, numecoup *new_top) { square const sq_departure = move_generation_stack[curr].departure; TraceFunctionEntry(__func__); TraceValue("%u",curr); TraceSquare(sq_departure); TraceFunctionParamListEnd(); while (curr<=CURRMOVE_OF_PLY(nbply) && move_generation_stack[curr].departure==sq_departure) { square const sq_arrival = move_generation_stack[curr].arrival; square const sq_capture = move_generation_stack[curr].capture; TraceSquare(sq_arrival); TraceEOL(); if (sq_capture==kingside_castling || sq_capture==queenside_castling) { if (castlingimok(sq_departure,sq_arrival)) { TraceText("accepting castling\n"); ++*new_top; move_generation_stack[*new_top] = move_generation_stack[curr]; } } else { if (are_all_imitator_arrivals_empty(sq_departure,sq_arrival)) { TraceText("accepting regular move\n"); ++*new_top; move_generation_stack[*new_top] = move_generation_stack[curr]; } } ++curr; } TraceFunctionExit(__func__); TraceFunctionResult("%u",curr); TraceFunctionResultEnd(); return curr; }
static boolean avoid_observing_if_imitator_blocked_rider_hopper(void) { boolean result; square const sq_observer = move_generation_stack[CURRMOVE_OF_PLY(nbply)].departure; square const sq_landing = move_generation_stack[CURRMOVE_OF_PLY(nbply)].arrival; piece_walk_type const p = get_walk_of_piece_on_square(sq_observer); Flags const flags = being_solved.spec[sq_observer]; numvec const step = -vec[interceptable_observation[observation_context].vector_index1]; square const sq_hurdle = sq_landing-step; numvec const diff_hurdle = sq_hurdle-sq_observer; empty_square(sq_observer); result = (have_all_imitators_hurdle(diff_hurdle) && are_all_imitator_arrivals_empty(sq_observer,sq_landing) && are_all_imitator_lines_clear(step,step,diff_hurdle)); occupy_square(sq_observer,p,flags); return result; }
static boolean castlingimok(square sq_departure, square sq_arrival) { boolean ret= false; piece_walk_type const p = get_walk_of_piece_on_square(sq_departure); Flags const flags = being_solved.spec[sq_departure]; /* I think this should work - clear the K, and move the Is, but don't clear the rook. */ /* If the Is crash into the R, the move would be illegal as the K moves first. */ /* The only other test here is for long castling when the Is have to be clear to move */ /* one step right (put K back first)as well as two steps left. */ /* But there won't be an I one sq to the left of a1 (a8) so no need to clear the R */ switch (sq_arrival-sq_departure) { case 2*dir_right: /* 00 - can short-circuit here (only follow K, if ok rest will be ok) */ empty_square(sq_departure); ret = (are_all_imitator_arrivals_empty(sq_departure, sq_departure+dir_right) && are_all_imitator_arrivals_empty(sq_departure, sq_departure+2*dir_right)); occupy_square(sq_departure,p,flags); break; case 2*dir_left: /* 000 - follow K, (and move K as well), then follow R */ empty_square(sq_departure); ret = (are_all_imitator_arrivals_empty(sq_departure, sq_departure+dir_left) && are_all_imitator_arrivals_empty(sq_departure, sq_departure+2*dir_left)); occupy_square(sq_departure+2*dir_left,p,flags); ret = (ret && are_all_imitator_arrivals_empty(sq_departure, sq_departure+dir_left) && are_all_imitator_arrivals_empty (sq_departure, sq_departure) && are_all_imitator_arrivals_empty(sq_departure, sq_departure+dir_right)); empty_square(sq_departure+2*dir_left); occupy_square(sq_departure,p,flags); break; } return ret; }
/* Validate an observation according to Imitators * @return true iff the observation is valid */ boolean imitator_validate_observation(slice_index si) { square const sq_observer = move_generation_stack[CURRMOVE_OF_PLY(nbply)].departure; boolean result; TraceFunctionEntry(__func__); TraceFunctionParam("%u",si); TraceFunctionParamListEnd(); TraceWalk(being_solved.board[sq_observer]);TraceEOL(); switch (being_solved.board[sq_observer]) { case King: case ErlKing: case Knight: case Wesir: case Dabbaba: case Fers: case Alfil: case Bucephale: case Giraffe: case Camel: case Zebra: case Okapi: case Bison: case Gnu: case Antilope: case Squirrel: case RootFiftyLeaper: case Leap15: case Leap16: case Leap24: case Leap25: case Leap35: case Leap36: case Leap37: case Pawn: case BerolinaPawn: case ReversePawn: { square const sq_landing = move_generation_stack[CURRMOVE_OF_PLY(nbply)].arrival; result = are_all_imitator_arrivals_empty(sq_observer,sq_landing); break; } case Queen: case Rook: case Bishop: case NightRider: case Elephant: case Waran: case Camelrider: case Zebrarider: case Gnurider: case Amazone: case Empress: case Princess: case RookHunter: case BishopHunter: case WesirRider: case FersRider: result = avoid_observing_if_imitator_blocked_rider(); break; case Mao: case Moa: result = avoid_observing_if_imitator_blocked_chinese_leaper(); break; case NonStopEquihopper: case NonStopOrix: result = avoid_observing_if_imitator_blocked_nonstop_equihopper(); break; case Orix: result = avoid_observing_if_imitator_blocked_orix(); break; case EquiHopper: if (interceptable_observation[observation_context].vector_index1==0) result = avoid_observing_if_imitator_blocked_nonstop_equihopper(); else result = avoid_observing_if_imitator_blocked_orix(); break; case Grasshopper: case NightriderHopper: case CamelRiderHopper: case ZebraRiderHopper: case GnuRiderHopper: case RookHopper: case BishopHopper: case KingHopper: case KnightHopper: result = avoid_observing_if_imitator_blocked_rider_hopper(); break; case ContraGras: result = avoid_observing_if_imitator_blocked_contragrasshopper(); break; case GrassHopper2: result = avoid_observing_if_imitator_blocked_grasshopper_n(2); break; case GrassHopper3: result = avoid_observing_if_imitator_blocked_grasshopper_n(3); break; case Elk: case RookMoose: case BishopMoose: result = avoid_observing_if_imitator_blocked_angle_hopper(angle_45); break; case Eagle: case RookEagle: case BishopEagle: result = avoid_observing_if_imitator_blocked_angle_hopper(angle_90); break; case Sparrow: case RookSparrow: case BishopSparrow: result = avoid_observing_if_imitator_blocked_angle_hopper(angle_135); break; default: result = true; break; } if (result) result = pipe_validate_observation_recursive_delegate(si); TraceFunctionExit(__func__); TraceFunctionResult("%u",result); TraceFunctionResultEnd(); return result; }