aimacode / aima-python

Python implementation of algorithms from Russell And Norvig's "Artificial Intelligence - A Modern Approach"
MIT License
8.07k stars 3.81k forks source link

Add Search Algorithm #1300

Open UditNayak opened 3 months ago

UditNayak commented 3 months ago

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.