/** * @brief Performs undo move. * * Takes back last move from move history and on the board. * * @return Nothing * @sa make_move() */ void undo_move(void) { int k; int i = get_last_move_i(); int j = get_last_move_j(); int color = get_last_move_color(); int count_stones = get_last_move_count_stones(); int stones[BOARD_SIZE_MAX * BOARD_SIZE_MAX][2]; if ( get_last_move_pass() ) { pop_move(); return; } get_last_move_stones(stones); set_vertex( EMPTY, i, j ); if ( count_stones > 0 ) { for ( k = 0; k < count_stones; k++ ) { set_vertex( color * -1, stones[k][0], stones[k][1] ); } if ( color == BLACK ) { set_black_captured( get_black_captured() - count_stones ); } else { set_white_captured( get_white_captured() - count_stones ); } } pop_move(); return; }
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; }
/* 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 move_execution_post_move_iterator_solve(slice_index si) { TraceFunctionEntry(__func__); TraceFunctionParam("%u",si); TraceFunctionParamListEnd(); TraceValue("%u",iteration_level);TraceValue("%u",current_level);TraceEOL(); pipe_solve_delegate(si); TraceValue("%u",iteration_level);TraceValue("%u",current_level);TraceEOL(); if (iteration_level==current_level) pop_move(); 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 move_execution_post_move_iterator_solve(slice_index si) { TraceFunctionEntry(__func__); TraceFunctionParam("%u",si); TraceFunctionParamListEnd(); pipe_solve_delegate(si); if (post_move_iteration_locked[nbply]) post_move_iteration_locked[nbply] = false; else { pop_move(); ++post_move_iteration_id[nbply]; TraceValue("%u",nbply);TraceValue("%u\n",post_move_iteration_id[nbply]); } TraceFunctionExit(__func__); TraceFunctionResultEnd(); }