Skip to content

Add Search Algorithm#1300

Open
UditNayak wants to merge 1 commit into
aimacode:masterfrom
UditNayak:search_algorithm_animation
Open

Add Search Algorithm#1300
UditNayak wants to merge 1 commit into
aimacode:masterfrom
UditNayak:search_algorithm_animation

Conversation

@UditNayak

Copy link
Copy Markdown

Issue: #1155 - Add Animations for Search Algorithms

Context:

This PR introduces animations for search algorithms, enhancing the user experience by providing a visual understanding of the algorithm's progression.

Changes Introduced:

  1. Animation Components:

    • Developed an AnimateProblem class to handle animations for various search algorithms.
    • Implemented methods for generating random lines, calculating straight-line distances, and transposing matrices.
  2. Integration with Search Algorithms:

    • Integrated the AnimateProblem class with different search algorithms such as A*, Weighted A*, BFS, DFS, UCS, and Best-First Search.
    • Utilized a dictionary to define the solvers and their corresponding f-value functions.
  3. User Interface and Visualization:

    • Created a matplotlib figure for displaying the animations.
    • Added visual indicators for obstacles, explored nodes, the current node, the initial state, and the goal state.
  4. Performance Optimizations:

    • Optimized the animation rendering to ensure smooth performance.
    • Minimized potential lag by efficiently handling the exploration and plotting of nodes.

weasdown added a commit to weasdown/aima-python that referenced this pull request Feb 5, 2025
@dmeoli

dmeoli commented Jun 26, 2026

Copy link
Copy Markdown
Collaborator

Thanks for this, @UditNayak — animated search on a grid is a genuinely nice addition for #1155. A few things to address before it can be merged: (1) It currently crashes on modern matplotlib: ax.scatter(*transpose(...)) raises 'missing x and y' whenever the point set is empty - this happens on the very first step because the root node's solution() is [] (and also if obstacles is empty). Please guard empty sets before scatter. (2) obstacles=random_lines(...) as a default argument is evaluated once at import time and shared across instances - please use obstacles=None and generate them inside init. (3) import heapq is unused (the frontier uses utils.PriorityQueue). (4) straight_line_distance duplicates utils.euclidean_distance - please reuse it. (5) Minor: use triple-quoted docstrings to match the repo style. Once it runs end-to-end on current matplotlib, happy to re-review!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants