/* Determine whether a specific piece delivers check to a specific side * @param observer_origin potentially delivering check ... * @note the piece on pos_checking must belong to advers(side) * @note sets observation_result */ void marscirce_is_square_observed(slice_index si) { circe_rebirth_context_elmt_type * const context = &circe_rebirth_context_stack[circe_rebirth_context_stack_pointer-1]; square const sq_target = move_generation_stack[CURRMOVE_OF_PLY(nbply)].capture; TraceFunctionEntry(__func__); TraceValue("%u",si); TraceFunctionParamListEnd(); assert(circe_rebirth_context_stack_pointer>0); observation_result = false; if (observing_walk[nbply]<Queen || observing_walk[nbply]>Bishop || CheckDir[observing_walk[nbply]][sq_target-context->rebirth_square]!=0) { if (is_square_empty(context->rebirth_square)) { TraceSquare(context->rebirth_square); TraceWalk(context->reborn_walk); TraceValue("%u",TSTFLAG(being_solved.spec[context->rebirth_square],White)); TraceValue("%u",TSTFLAG(being_solved.spec[context->rebirth_square],Black)); TraceEOL(); occupy_square(context->rebirth_square,context->reborn_walk,context->reborn_spec); pipe_is_square_observed_delegate(si); empty_square(context->rebirth_square); } } TraceFunctionExit(__func__); TraceFunctionResultEnd(); }
unsigned int pawn_get_no_capture_length(Side side, square sq_departure) { unsigned int result; SquareFlags const base_square = WhBaseSq+side; SquareFlags const doublestep_square = WhPawnDoublestepSq+side; TraceFunctionEntry(__func__); TraceEnumerator(Side,side); TraceSquare(sq_departure); TraceFunctionParamListEnd(); if (TSTFLAG(sq_spec[sq_departure],base_square)) { if (CondFlag[einstein]) result = 3; else if (circe_variant.determine_rebirth_square==circe_determine_rebirth_square_equipollents || CondFlag[normalp] || circe_variant.determine_rebirth_square==circe_determine_rebirth_square_cage || get_walk_of_piece_on_square(sq_departure)==Orphan /* we are generating for a pawned Orphan! */ || TSTFLAG(sq_spec[sq_departure],Wormhole)) result = 1; else result = 0; } else if (TSTFLAG(sq_spec[sq_departure],doublestep_square)) result = 2; else result = 1; TraceFunctionExit(__func__); TraceFunctionResult("%u",result); TraceFunctionResultEnd(); return result; }
static boolean is_not_king_captures_guarded_king(numecoup n) { square const sq_observer = move_generation_stack[CURRMOVE_OF_PLY(nbply)].departure; square const sq_observee = move_generation_stack[CURRMOVE_OF_PLY(nbply)].capture; boolean result; TraceFunctionEntry(__func__); TraceFunctionParam("%u",n); TraceFunctionParamListEnd(); if (TSTFLAG(being_solved.spec[sq_observer],Royal) && TSTFLAG(being_solved.spec[sq_observee],Royal)) { siblingply(advers(trait[nbply])); push_observation_target(move_generation_stack[n].capture); result = !is_square_observed(EVALUATE(observer)); finply(); } else result = true; TraceFunctionExit(__func__); TraceFunctionResult("%u",result); TraceFunctionResultEnd(); return result; }
boolean WriteSpec(output_engine_type const * engine, FILE *file, Flags sp, piece_walk_type p, boolean printcolours) { boolean result = false; if (is_piece_neutral(sp)) { (*engine->fputc)(tolower(ColourTab[colour_neutral][0]),file); result = true; } else if (printcolours) { if (areColorsSwapped) { if (TSTFLAG(sp,White)) (*engine->fputc)(tolower(ColourTab[colour_black][0]),file); if (TSTFLAG(sp,Black)) (*engine->fputc)(tolower(ColourTab[colour_white][0]),file); } else { if (TSTFLAG(sp,White)) (*engine->fputc)(tolower(ColourTab[colour_white][0]),file); if (TSTFLAG(sp,Black)) (*engine->fputc)(tolower(ColourTab[colour_black][0]),file); } } { piece_flag_type spname; for (spname = nr_sides; spname<nr_piece_flags; ++spname) if ((spname!=Volage || !CondFlag[volage]) && (spname!=Patrol || !CondFlag[patrouille]) && (spname!=Beamtet || !CondFlag[beamten]) && (spname!=Royal || !is_king(p)) && TSTFLAG(sp, spname)) { char const *curr = PieSpTab[spname-nr_sides]; while (*curr!=0) { if (isupper(*curr)) (*engine->fputc)(tolower(*curr),file); ++curr; } result = true; } } return result; }
static void write_transfer(output_plaintext_move_context_type *context, move_effect_journal_index_type removal, move_effect_journal_index_type addition) { next_context(context,removal,"[","]"); write_complete_piece(context, move_effect_journal[removal].u.piece_removal.flags, move_effect_journal[removal].u.piece_removal.walk, move_effect_journal[removal].u.piece_removal.on); (*context->engine->fprintf)(context->file,"%s",(*context->symbol_table)[output_symbol_right_arrow]); if (move_effect_journal[removal].u.piece_removal.flags !=move_effect_journal[addition].u.piece_addition.added.flags || (TSTFLAG(move_effect_journal[addition].u.piece_addition.added.flags,Royal) && is_king(move_effect_journal[removal].u.piece_removal.walk) && !is_king(move_effect_journal[addition].u.piece_addition.added.walk))) { WriteSpec(context->engine,context->file, move_effect_journal[addition].u.piece_addition.added.flags, move_effect_journal[addition].u.piece_addition.added.walk, false); WriteWalk(context->engine,context->file,move_effect_journal[addition].u.piece_addition.added.walk); } else if (move_effect_journal[removal].u.piece_removal.walk !=move_effect_journal[addition].u.piece_addition.added.walk) WriteWalk(context->engine,context->file,move_effect_journal[addition].u.piece_addition.added.walk); WriteSquare(context->engine,context->file,move_effect_journal[addition].u.piece_addition.added.on); }
boolean amu_count_observation(slice_index si) { boolean result; TraceFunctionEntry(__func__); TraceFunctionParamListEnd(); if (are_we_counting) { square const sq_departure = move_generation_stack[CURRMOVE_OF_PLY(nbply)].departure; if (get_walk_of_piece_on_square(sq_departure)==observing_walk[nbply] && TSTFLAG(being_solved.spec[sq_departure],trait[nbply])) { /* this deals correctly with double attacks by the same piece (e.g. a rose) */ if (single_attacker_departure==sq_departure) result = false; else { ++amu_attack_count; single_attacker_departure = sq_departure; result = amu_attack_count==2; } } else result = false; } else result = pipe_validate_observation_recursive_delegate(si); TraceFunctionExit(__func__); TraceFunctionResult("%u",result); TraceFunctionResultEnd(); return result; }
boolean pawn_check(validator_id evaluate) { square const sq_target = move_generation_stack[CURRMOVE_OF_PLY(nbply)].capture; SquareFlags const capturable = trait[nbply]==White ? CapturableByWhPawnSq : CapturableByBlPawnSq; boolean result = false; TraceFunctionEntry(__func__); TraceFunctionParamListEnd(); TraceSquare(sq_target); TraceEOL(); if (TSTFLAG(sq_spec[sq_target],capturable) || observing_walk[nbply]==Orphan || observing_walk[nbply]>=Hunter0) { numvec const dir_forward = trait[nbply]==White ? dir_up : dir_down; numvec const dir_forward_right = dir_forward+dir_right; numvec const dir_forward_left = dir_forward+dir_left; if (pawn_test_check(sq_target-dir_forward_right,sq_target,evaluate)) result = true; else if (pawn_test_check(sq_target-dir_forward_left,sq_target,evaluate)) result = true; else if (en_passant_test_check(dir_forward_right,&pawn_test_check,evaluate)) result = true; else if (en_passant_test_check(dir_forward_left,&pawn_test_check,evaluate)) result = true; } TraceFunctionExit(__func__); TraceFunctionResult("%u",result); TraceFunctionResultEnd(); return result; }
/* Determine whether a side observes a specific square * @param si identifies the tester slice * @note sets observation_result */ void marscirce_iterate_observers(slice_index si) { circe_rebirth_context_elmt_type * const context = &circe_rebirth_context_stack[circe_rebirth_context_stack_pointer]; Side const side_observing = trait[nbply]; square const *observer_origin; square const sq_target = move_generation_stack[CURRMOVE_OF_PLY(nbply)].capture; TraceFunctionEntry(__func__); TraceValue("%u",si); TraceFunctionParamListEnd(); observation_result = false; context->relevant_ply = nbply; for (observer_origin = boardnum; *observer_origin; ++observer_origin) if (*observer_origin!=sq_target /* no auto-observation */ && TSTFLAG(being_solved.spec[*observer_origin],side_observing) && get_walk_of_piece_on_square(*observer_origin)==observing_walk[nbply]) { context->rebirth_from = *observer_origin; context->reborn_walk = observing_walk[nbply]; context->reborn_spec = being_solved.spec[context->rebirth_from]; context->relevant_side = advers(side_observing); context->relevant_square = context->rebirth_from; pipe_is_square_observed_delegate(si); if (observation_result) break; } 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(); }
/* Determine whether a side is in check * @param si identifies the check tester * @param side_in_check which side? * @return true iff side_in_check is in check according to slice si */ boolean circe_assassin_all_piece_observation_tester_is_in_check(slice_index si, Side side_attacked) { boolean result = false; square const *bnp; TraceFunctionEntry(__func__); TraceFunctionParam("%u",si); TraceEnumerator(Side,side_attacked,""); TraceFunctionParamListEnd(); for (bnp = boardnum; *bnp; ++bnp) if (TSTFLAG(being_solved.spec[*bnp],side_attacked)) { replace_observation_target(*bnp); if (is_square_observed(EVALUATE(check))) { result = true; break; } } TraceFunctionExit(__func__); TraceFunctionResult("%u",result); TraceFunctionResultEnd(); return result; }
boolean magic_enforce_observer(slice_index si) { boolean result; TraceFunctionEntry(__func__); TraceFunctionParamListEnd(); if (are_we_finding_magic_views[nbply]) { square const sq_observer = move_generation_stack[CURRMOVE_OF_PLY(nbply)].departure; if (TSTFLAG(being_solved.spec[sq_observer],Magic)) { if (pipe_validate_observation_recursive_delegate(si)) identify_line(); result = false; /* we need all views */ } else result = false; } else result = pipe_validate_observation_recursive_delegate(si); TraceFunctionExit(__func__); TraceFunctionResult("%u",result); TraceFunctionResultEnd(); return result; }
/* Is the placed white king in check from a particular direction? * @param dir direction * @return true iff the placed white king is in check from dir */ static boolean check_from_direction(int dir) { square curr = being_solved.king_square[White]-dir; boolean const is_diagonal = SquareCol(curr)==SquareCol(being_solved.king_square[White]); boolean result; TraceFunctionEntry(__func__); TraceFunctionParam("%d",dir); TraceFunctionParamListEnd(); while (is_square_empty(curr)) curr -= dir; if (TSTFLAG(being_solved.spec[curr],Black)) { piece_walk_type const checker = get_walk_of_piece_on_square(curr); result = checker==Queen || checker==(is_diagonal ? Bishop : Rook); } else result = false; 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 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(); }
void intelligent_place_white_rider(unsigned int placed_index, square placed_on, void (*go_on)(void)) { piece_walk_type const placed_type = white[placed_index].type; Flags const placed_flags = white[placed_index].flags; square const placed_comes_from = white[placed_index].diagram_square; int const dir = GuardDir[placed_type-Pawn][placed_on].dir; square const target = GuardDir[placed_type-Pawn][placed_on].target; TraceFunctionEntry(__func__); TraceFunctionParam("%u",placed_index); TraceSquare(placed_on); TraceFunctionParamListEnd(); switch (dir) { case guard_dir_check_uninterceptable: break; case guard_dir_guard_uninterceptable: if (placed_index>index_of_guarding_piece && intelligent_reserve_officer_moves_from_to(White, placed_comes_from, placed_type, placed_on)) { occupy_square(placed_on,placed_type,placed_flags); (*go_on)(); intelligent_unreserve(); } break; default: if (intelligent_reserve_officer_moves_from_to(White, placed_comes_from, placed_type, placed_on)) { occupy_square(placed_on,placed_type,placed_flags); if (placed_index>index_of_guarding_piece || dir==0 || TSTFLAG(being_solved.spec[target],Black) || !is_line_empty(placed_on,target,dir)) (*go_on)(); else intelligent_intercept_guard_by_white(target,dir,go_on); intelligent_unreserve(); } break; } TraceFunctionExit(__func__); TraceFunctionResultEnd(); }
/* Undo the neutralisation a half-neutral piece * @param curr identifies the neutralisation effect */ void undo_half_neutral_neutralisation(move_effect_journal_entry_type const *entry) { square const on = entry->u.half_neutral_phase_change.on; Side const from = entry->u.half_neutral_phase_change.side; TraceFunctionEntry(__func__); TraceFunctionParamListEnd(); assert(TSTFLAG(being_solved.spec[on],White)); assert(TSTFLAG(being_solved.spec[on],Black)); assert(is_piece_neutral(being_solved.spec[on])); --being_solved.number_of_pieces[advers(from)][get_walk_of_piece_on_square(on)]; occupy_square(on,get_walk_of_piece_on_square(on),being_solved.spec[on]&~BIT(advers(from))); TraceFunctionExit(__func__); TraceFunctionResultEnd(); }
/* Generate moves for a piece with a specific walk from a specific departure * square. * @note the piece on the departure square need not necessarily have walk p */ void marscirce_generate_moves_enforce_rex_exclusive(slice_index si) { TraceFunctionEntry(__func__); TraceValue("%u",si); TraceFunctionParamListEnd(); if (!TSTFLAG(being_solved.spec[curr_generation->departure],Royal)) pipe_move_generation_delegate(si); TraceFunctionExit(__func__); TraceFunctionResultEnd(); }
/* Deneutralise a half-neutral piece * @param on position of the piece to be changed * @param to new side of half-neutral piece */ static void do_deneutralisation(square on, Side to) { move_effect_journal_entry_type * const entry = move_effect_journal_allocate_entry(move_effect_half_neutral_deneutralisation,move_effect_reason_half_neutral_deneutralisation); TraceFunctionEntry(__func__); TraceSquare(on); TraceEnumerator(Side,to); TraceFunctionParamListEnd(); entry->u.half_neutral_phase_change.on = on; entry->u.half_neutral_phase_change.side = to; assert(TSTFLAG(being_solved.spec[on],White)); assert(TSTFLAG(being_solved.spec[on],Black)); assert(is_piece_neutral(being_solved.spec[on])); --being_solved.number_of_pieces[advers(to)][get_walk_of_piece_on_square(on)]; occupy_square(on,get_walk_of_piece_on_square(on),being_solved.spec[on]&~BIT(advers(to))); TraceFunctionExit(__func__); TraceFunctionResultEnd(); }
static boolean is_piece_illegally_observed(Side side, square z) { boolean result; if (TSTFLAG(being_solved.spec[z],side)) { trait[nbply] = side; /* from Madrasi's perspective! */ result = madrasi_is_moving_piece_observed(z); } else result = false; 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 circe_kamikaze_capture_fork_solve(slice_index si) { 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; TraceFunctionEntry(__func__); TraceFunctionParam("%u",si); TraceFunctionParamListEnd(); binary_solve_if_then_else(si,!TSTFLAG(move_effect_journal[movement].u.piece_movement.movingspec,Kamikaze)); TraceFunctionExit(__func__); TraceFunctionResultEnd(); }
static boolean mover_is_not_paralysing(numecoup n) { boolean result; TraceFunctionEntry(__func__); TraceFunctionParamListEnd(); result = !TSTFLAG(being_solved.spec[move_generation_stack[n].departure],Paralysing); TraceFunctionExit(__func__); TraceFunctionResult("%u",result); TraceFunctionResultEnd(); return result; }
/* Determine whether a side observes a specific square * @param side_observing the side * @note sets observation_validation_result */ void marscirce_is_square_observed_enforce_rex_exclusive(slice_index si) { circe_rebirth_context_elmt_type * const context = &circe_rebirth_context_stack[circe_rebirth_context_stack_pointer]; TraceFunctionEntry(__func__); TraceValue("%u",si); TraceFunctionParamListEnd(); if (!TSTFLAG(context->reborn_spec,Royal)) pipe_is_square_observed_delegate(si); TraceFunctionExit(__func__); TraceFunctionResultEnd(); }
/* Determine the length of a move in the presence of forced squares; the higher * the value the more likely the move is going to be played. * @return a value expressing the precedence of this move */ int forced_squares_measure_length(void) { square const sq_arrival = move_generation_stack[CURRMOVE_OF_PLY(nbply)].arrival; SquareFlags const flag = trait[nbply]==White ? WhForcedSq : BlForcedSq; int const result = TSTFLAG(sq_spec[sq_arrival],flag); TraceFunctionEntry(__func__); TraceFunctionParamListEnd(); TraceValue("%x\n",sq_spec[sq_arrival]); 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 goal_doublemate_reached_tester_solve(slice_index si) { TraceFunctionEntry(__func__); TraceFunctionParam("%u",si); TraceFunctionParamListEnd(); TraceValue("%u",nbply); TraceValue("%u",parent_ply[nbply]); TraceEOL(); pipe_this_move_doesnt_solve_if(si, !TSTFLAG(goal_preprequisites_met[parent_ply[nbply]], goal_doublemate)); TraceFunctionExit(__func__); TraceFunctionResultEnd(); }
static boolean find_flights(slice_index si, Side side_in_check, unsigned int nr_flights_to_find) { unsigned int nr_flights_found = 0; square const save_king_square = being_solved.king_square[side_in_check]; piece_walk_type const king_walk = get_walk_of_piece_on_square(save_king_square); Flags const king_flags = being_solved.spec[save_king_square]; square const save_departure = curr_generation->departure ; TraceFunctionEntry(__func__); TraceFunctionParam("%u",si); TraceFunctionParamListEnd(); siblingply(side_in_check); curr_generation->departure = save_king_square; move_generation_current_walk = king_walk; generate_moves_for_piece_based_on_walk(); empty_square(save_king_square); while (encore()) { being_solved.king_square[side_in_check] = move_generation_stack[CURRMOVE_OF_PLY(nbply)].arrival; if ((is_square_empty(being_solved.king_square[side_in_check]) || TSTFLAG(being_solved.spec[being_solved.king_square[side_in_check]],advers(side_in_check))) && being_solved.king_square[side_in_check]!=being_solved.king_square[advers(side_in_check)] && !pipe_is_in_check_recursive_delegate(si,side_in_check)) ++nr_flights_found; pop_move(); } being_solved.king_square[side_in_check] = save_king_square; occupy_square(save_king_square,king_walk,king_flags); curr_generation->departure = save_departure; finply(); TraceFunctionExit(__func__); TraceFunctionResult("%u",nr_flights_found>nr_flights_to_find); TraceFunctionResultEnd(); return nr_flights_found>nr_flights_to_find; }
static void generate_moves_for_possibly_confronted_piece(slice_index si, numvec dir_confronter) { square const confronter_pos = curr_generation->departure+dir_confronter; TraceFunctionEntry(__func__); TraceFunctionParam("%u",si); TraceFunctionParamListEnd(); if (TSTFLAG(being_solved.spec[confronter_pos],advers(trait[nbply]))) pipe_move_generation_differnt_walk_delegate(si,get_walk_of_piece_on_square(confronter_pos)); else pipe_move_generation_delegate(si); TraceFunctionExit(__func__); TraceFunctionResultEnd(); }
static boolean is_not_unsupported_patrol_capture(numecoup n) { boolean result; TraceFunctionEntry(__func__); TraceFunctionParamListEnd(); if (TSTFLAG(being_solved.spec[move_generation_stack[n].departure],Patrol)) result = is_mover_supported(n); else result = true; TraceFunctionExit(__func__); TraceFunctionResult("%u",result); TraceFunctionResultEnd(); return result; }
static void intercept_queen_diag(void) { square const placed_on = stack_top->placed_on; int const dir_diag = GuardDir[Bishop-Pawn][placed_on].dir; square const target_diag = GuardDir[Bishop-Pawn][placed_on].target; TraceFunctionEntry(__func__); TraceFunctionParamListEnd(); if (dir_diag==0 || TSTFLAG(being_solved.spec[target_diag],Black) || !is_line_empty(placed_on,target_diag,dir_diag)) (*stack_top->go_on)(); else intelligent_intercept_guard_by_white(target_diag,dir_diag,stack_top->go_on); TraceFunctionExit(__func__); TraceFunctionResultEnd(); }
static boolean annanises(Side side, square rear, square front) { boolean result = false; TraceFunctionEntry(__func__); TraceEnumerator(Side,side,""); TraceSquare(rear); TraceSquare(front); TraceFunctionParamListEnd(); if (TSTFLAG(being_solved.spec[rear],side)) { Flags const mask = BIT(side)|BIT(Royal); switch(annan_type) { case ConditionTypeA: result = true; break; case ConditionTypeB: result = !TSTFULLFLAGMASK(being_solved.spec[rear],mask); break; case ConditionTypeC: result = !TSTFULLFLAGMASK(being_solved.spec[front],mask); break; case ConditionTypeD: result = !TSTFULLFLAGMASK(being_solved.spec[rear],mask) && !TSTFULLFLAGMASK(being_solved.spec[front],mask); break; default: assert(0); break; } } TraceFunctionExit(__func__); TraceFunctionResult("%u",result); TraceFunctionResultEnd(); return result; }
/* Neutralise a half-neutral piece * @param on position of the piece to be changed */ static void do_neutralisation(square on) { move_effect_journal_entry_type * const entry = move_effect_journal_allocate_entry(move_effect_half_neutral_neutralisation,move_effect_reason_half_neutral_neutralisation); Side const from = TSTFLAG(being_solved.spec[on],White) ? White : Black; TraceFunctionEntry(__func__); TraceSquare(on); TraceEnumerator(Side,from); TraceFunctionParamListEnd(); entry->u.half_neutral_phase_change.on = on; entry->u.half_neutral_phase_change.side = from; occupy_square(on,get_walk_of_piece_on_square(on),being_solved.spec[on]|BIT(advers(from))); ++being_solved.number_of_pieces[advers(from)][get_walk_of_piece_on_square(on)]; TraceFunctionExit(__func__); TraceFunctionResultEnd(); }
/* Validate an observation according to Patrol Chess * @return true iff the observation is valid */ boolean patrol_validate_observation(slice_index si) { boolean result; TraceFunctionEntry(__func__); TraceFunctionParam("%u",si); TraceFunctionParamListEnd(); if (TSTFLAG(being_solved.spec[move_generation_stack[CURRMOVE_OF_PLY(nbply)].departure],Patrol)) result = (is_mover_supported(CURRMOVE_OF_PLY(nbply)) && pipe_validate_observation_recursive_delegate(si)); else result = pipe_validate_observation_recursive_delegate(si); TraceFunctionExit(__func__); TraceFunctionResult("%u",result); TraceFunctionResultEnd(); return result; }