diff --git a/main.py b/main.py index 6d6e3f6..f9a02f1 100644 --- a/main.py +++ b/main.py @@ -22,7 +22,7 @@ def main(): start = time.time() solution = solve_game(game) - print(f"\rFound solution with {len(solution)} steps.") + print(f"\rFound solution with {len(solution)} steps. {' '*20}") print(format_instructions(solution, start)) if __name__ == "__main__": diff --git a/vial_solver.py b/vial_solver.py index 5f50ffa..84104b1 100644 --- a/vial_solver.py +++ b/vial_solver.py @@ -31,14 +31,16 @@ def solve_game(starting_state: Game): while len(states) > 0: (current_state, moves), value = states.extract_min() - if len(moves) > moves_amount: - moves_amount = len(moves) - print(f"{len(states) + 1} ({len(attempted_states)})") if amount_done + 0.00125 < len(moves)/value: amount_done = (len(moves)/value) print_progress(amount_done) + if len(moves) > moves_amount: + moves_amount = len(moves) + print(f"{len(states) + 1} ({len(attempted_states)}){' '*20}", + end="\r") + last_to_vial = moves[-1][1] if len(moves) > 1 else None possible_moves = current_state.possible_moves(last_to_vial) for from_vial, to_vial in possible_moves: @@ -57,7 +59,6 @@ def solve_game(starting_state: Game): new_state_value = new_state.min_moves + len(new_state_moves) states.insert((new_state, new_state_moves), new_state_value) - print("\r", end="") raise NoSolutions() def format_instructions(instructions, start_time):