Maze Solver: BFS and DFS - AI Lab CS 39002

Choose a study mode

Play Quiz
Study Flashcards
Spaced Repetition
Chat to Lesson

Podcast

Play an AI-generated podcast conversation about this lesson
Download our mobile app to listen on the go
Get App

Questions and Answers

In the context of the maze solver assignment, why might the path found by DFS not be the shortest path?

DFS explores paths to their full depth before exploring other branches, it doesn't guarantee finding the shortest path. It reports the valid path found first, not necessarily the path with the fewest steps.

Explain how bi-directional BFS can improve the efficiency of route-finding compared to standard BFS, particularly in the context of Assignment 2.

Bi-directional BFS searches from both the start and end points simultaneously, meeting in the middle. This can significantly reduce the number of nodes explored, as the search space expands exponentially from both ends, leading to faster convergence.

In the treasure-seeking task (Assignment 3), what is the role of the heuristic in Best-First Search, and how does the choice of heuristic influence the search process?

The heuristic estimates the distance or cost from the current cell to the treasure. The choice of heuristic influences the search process by guiding the algorithm towards cells that appear closer to the treasure, affecting both the path taken and the efficiency of the search.

In Uniform Cost Search (Assignment 4), how does it differ from BFS, and when is Uniform Cost Search preferred?

<p>Uniform Cost Search explores paths based on the cumulative cost from the starting node, while BFS explores based on the number of edges. Uniform Cost Search is preferred when the edges have varying costs, as it guarantees finding the lowest-cost path.</p> Signup and view all the answers

In the 8-puzzle problem (Assignment 5), what is the purpose of defining heuristic functions like 'number of misplaced tiles' and 'sum of Manhattan distances', and how do they contribute to the efficiency of the A* search algorithm?

<p>Heuristic functions estimate the remaining cost to reach the goal state, guiding A* to explore more promising states first. 'Number of misplaced tiles' and 'sum of Manhattan distances' heuristics directs the A* search toward the goal, reducing the number of explored nodes and improving efficiency.</p> Signup and view all the answers

Explain how you would adapt the A* search algorithm for a robot path planning problem (Assignment 6) in a 2D grid with obstacles, specifically focusing on how the heuristic function is used and how the algorithm avoids obstacles.

<p>The heuristic function estimates the distance from the current cell to the goal, considering the grid. To avoid obstacles, valid moves in A* consider only unblocked adjacent cells, and paths through blocked cells are not explored. The algorithm maintains a closed list to prevent revisiting already explored grid locations.</p> Signup and view all the answers

How can BFS and DFS be adapted to explore game states in a simple turn-based game like Tic-Tac-Toe (Assignment 7)? Discuss their limitations in this context.

<p>BFS and DFS can be used to explore all possible game states by treating each state as a node in a search tree. BFS guarantees finding the shortest path to a win, while DFS explores deeply but doesn't guarantee optimality. However in practice their performance can be poor because they cannot look at the values of future game states in order to make correct decisions.</p> Signup and view all the answers

In Assignment 8, describe how you would modify the A* search algorithm to handle multiple goals with differing priorities or costs in a navigation problem.

<p>Modify A* by adjusting the cost function to incorporate the priority or cost of each goal, considering the order in which goals must be achieved. This can be implemented by adding the goal's cost to the path cost when that goal is reached, influencing the search to favor paths that achieve higher-priority goals earlier.</p> Signup and view all the answers

How is the A* search algorithm applied in Assignment 9 to optimize task scheduling, and what role does the heuristic play in guiding the search for an optimal schedule?

<p>A* is used to find the optimal task schedule by treating each possible schedule as a state. The heuristic estimates the remaining time to complete all tasks, guiding A* to explore schedules that minimize the total completion time. The algorithm can then choose an optimal schedule by choosing the schedule with the lowest cost (time).</p> Signup and view all the answers

When comparing search algorithms like BFS, DFS, and A* (Assignment 10), what metrics would be most important to consider, and explain why each is significant.

<p>Important metrics include efficiency (nodes explored, time taken, memory usage) and optimality (guarantee of finding the best solution). Efficiency is important for practical applicability, while optimality ensures the solution is the best possible within the given constraints.</p> Signup and view all the answers

In the context of solving AI-based search problems, explain the concept of local optimization techniques like Hill Climbing, and discuss their strengths and limitations.

<p>Hill Climbing iteratively improves a solution by making small changes and accepting those that improve the objective function. Strengths: simple and efficient for some problems. Limitations: can get stuck in local optima, failing to find the global optimum.</p> Signup and view all the answers

Explain how a Genetic Algorithm (GA) can be applied to solve AI-based search problems, detailing the roles of key GA components such as selection, crossover, and mutation.

<p>A Genetic Algorithm uses a population of candidate solutions and evolves them over generations. Selection chooses the best solutions to reproduce, crossover combines the genetic material of two parents to create offspring, and mutation introduces random changes to maintain diversity and avoid premature convergence.</p> Signup and view all the answers

In the Water-Jugs problem (Assignment 13), how does the Minimax algorithm determine the optimal move for the AI player, and what role does the utility function play in this process?

<p>The Minimax algorithm explores all possible moves for both the AI and the opponent. The utility function evaluates the state resulting from each move. The AI aims to maximize its score, assuming the opponent plays optimally to minimize the AI's score.</p> Signup and view all the answers

In the 4-Queens problem (Assignment 14), describe how alpha-beta pruning enhances the efficiency of the Minimax algorithm.

<p>Alpha-beta pruning eliminates branches of the search tree that are guaranteed to be worse than the best already found. It avoids evaluation of branches that could not possibly influence the final decision, significantly speeding up the search.</p> Signup and view all the answers

Explain how transforming the Tower of Hanoi into a competitive two-player game (Assignment 15) allows for the implementation of adversarial search strategies.

<p>By turning the problem into a competitive game, each player aims to move the largest disk to the target rod. It requires each player to consider the other player's possible responses and optimize their moves to win the game.</p> Signup and view all the answers

Flashcards

DFS (Depth-First Search)

A search algorithm that explores all possible paths and reports one valid path, not necessarily the shortest.

BFS (Breadth-First Search)

A search algorithm that finds the shortest path by exploring all neighbors at the present depth prior to moving on to the nodes at the next depth level.

Bi-Directional Search

A search algorithm that minimizes the number of explored nodes by searching from both the initial and goal states simultaneously.

Best-First Search

A search algorithm that finds a treasure in grid, and each cell has a heuristic value representing its "closeness" to the treasure.

Signup and view all the flashcards

Uniform Cost Search

A search algorithm that find the minimum-cost path between two nodes in a weighted graph.

Signup and view all the flashcards

A* Search

A search algorithm that combines the cost to reach a state (g(n)) with the heuristic estimate to the goal h(n).

Signup and view all the flashcards

Manhattan Distance

Estimates the sum of the absolute differences between the current and target positions of each tile.

Signup and view all the flashcards

Misplaced Tiles

Counts the number of tiles not in their correct positions.

Signup and view all the flashcards

Greedy Best-First Search (GBFS)

Considers only the heuristic value (h(n)) for each state.

Signup and view all the flashcards

Minimax Algorithm

An adversarial search algorithm used in game theory to find the best move for a player, assuming the opponent will play optimally.

Signup and view all the flashcards

Alpha-Beta Pruning

An optimization technique used to reduce the number of nodes evaluated by the Minimax algorithm.

Signup and view all the flashcards

Study Notes

General Course Information

  • The course code is CS 39002.
  • The course title is Artificial Intelligence Laboratory (AI Lab).
  • The LTP structure is 2-0-0-2, totaling 1 credit.
  • The faculty is Rajdeep Chatterjee, Ph.D., email [email protected], room F101(c), First Floor, Block-C, Campus-14.
  • The course is offered to the School of Computer Engineering.
  • Course aims to provide skills for designing and analyzing AI algorithms, enable work on AI tools, and work towards solving real-life problems.
  • Python and VS Code IDE or Google Colab can be used for implementation.
  • KIIT mail ID must be used for Google Colab Notebooks, named "RollNo_AssignmentNo.ipynb".
  • Students should gain a brief understanding of it's searching techniques and adversarial search.

Assignment 1: Maze Solver using BFS and DFS

  • Objective: Implement Breadth-First Search (BFS) and Depth-First Search (DFS) to solve mazes.
  • Problem: Given a grid maze where 0 is a wall and 1 is a path, find the shortest path from start to end.
  • Tasks include using BFS, DFS, and comparing nodes explored by each.

Assignment 2: Route Finder Using Bi-Directional BFS/DFS

  • Objective: Solve a navigation problem using Bi-directional BFS/DFS.
  • Problem: Find the shortest path between two locations in a city map represented as a graph.
  • Tasks involve implementing Bi-directional BFS, comparing performance, and visualizing the search using Python libraries.
  • Objective: Find a treasure in a grid using Best-First Search.
  • Problem: Locate a treasure hidden in a grid where each cell has a heuristic value indicating closeness.
  • Tasks include using Manhattan distance, moving to the most promising cell first with the minimum heuristic value, and analyzing how heuristic choice affects performance.

Assignment 4: Uniform Cost Search for Optimal Path

  • Objective: Implement Uniform Cost Search for a weighted graph.
  • Problem: Find the minimum-cost path between two nodes in a weighted graph.
  • Tasks are to represent the graph as an adjacency list, implement Uniform Cost Search, and compare with BFS.

Assignment 5: A Search for a Puzzle Solver

  • Objective: Solve the 8-puzzle using A* search.
  • Problem: Solve the 8-puzzle by sliding tiles to achieve a goal state using A* search.
  • Tasks require defining heuristic functions (H1: misplaced tiles, H2: Manhattan distance sum), implementing A* with both, and comparing performance based on nodes explored and solution depth.

Assignment 6: Path Planning for a Robot

  • Objective: Use A* Search to find an optimal path for a robot navigating a 2D grid with obstacles.
  • Tasks include implementing A* with Manhattan and Euclidean distance heuristics and comparing A* with BFS and Uniform Cost Search.

Assignment 7: Game AI Using Search Algorithms

  • Objective: Implement AI for a simple turn-based game using search algorithms.
  • Problem: Design an AI agent to play a game like Tic-Tac-Toe using search algorithms.
  • Tasks include using BFS/DFS and A* Search with a heuristic function.

Assignment 8: Navigation with Multiple Goals

  • Objective: Solve a problem with multiple goals using search algorithms.
  • Problem: A robot in a grid needs to collect items (goals) before reaching an exit; each goal has a different priority or cost.
  • Tasks include using BFS/DFS and implementing A* or Uniform Cost Search for weighted scenarios and analyzing path length vs. goal priority.

Assignment 9: AI Planner Using A for Task Scheduling

  • Objective: Use A* Search to optimize task scheduling.
  • Problem: Schedule a set of tasks to minimize total time, considering dependencies and durations.
  • Tasks require representing tasks as a directed graph, using A* with remaining tasks' duration estimations, and comparing results with a greedy algorithm.

Assignment 10: Comparative Study

  • Objective: Evaluate and compare different search algorithms.
  • Focus: Evaluate BFS, DFS, Bi-directional BFS, Uniform Cost Search, Best-First Search, and A* Search on a given domain like pathfinding.
  • Tasks require analyzing efficiency (nodes explored, time taken) and optimality, and creating visualizations.

Assignment 11: Local Optimization Techniques

  • Implementation of local optimization techniques, such as Hill Climbing, for solving AI-based search problems

Assignment 12: Genetic Algorithm

  • Assignment involves implementation of Genetic Algorithm (GA) for solving AI-based search problems.
  • Objective: Develop a competitive Water-Jugs game using the Minimax algorithm.
  • Problem: Two players try to reach a target volume T using jugs of capacities A and B.
  • Tasks include implementing the Water-Jugs problem, using the Minimax algorithm, defining a utility function, integrating alpha-beta pruning, allowing player interaction, and comparing execution times.
  • Objective: Design a competitive 4-Queens puzzle.
  • Involves placing queens on a 4x4 chessboard such that no two queens threaten each other.
  • Implement the Minimax algorithm, Alpha-beta pruning is used for optimization.
  • Tasks include representing the board, evaluation of moves, and analysis of performance.
  • Objective: Transform Tower of Hanoi into a two-player game using adversarial search.
  • Problem: Players move disks between three rods, and the player moving the largest disk to the target wins.
  • Tasks include representing the rods and disks, implementing the Minimax algorithm with alpha-beta pruning, defining a utility function, and analyzing performance. Game ends when all disks are moved.
  • Objective: Implement and compare A* and Greedy Best-First Search (GBFS) for solving the 8-Puzzle.
  • Problem: Arrange tiles in a 3x3 grid in a specified order.
  • Tasks include modeling the puzzle, implementing Manhattan distance and misplaced tiles heuristics, comparing the performance of the used algorithms, and ensuring the solution handles unsolvable configurations.

Course Evaluation

  • The total number of assignments is 16.
  • Continuous Evaluation (daily basis): 20 Marks
  • Lab Test-I (pre-midterm) and Lab Test-II (post-midterm): 15 Marks
  • Quiz: 10 Marks
  • Viva: 05 Marks
  • Lab record hard-copy (hand written complete code): 20 Marks
  • Sessional Test (External): 30 Marks

Studying That Suits You

Use AI to generate personalized quizzes and flashcards to suit your learning preferences.

Quiz Team

Related Documents

More Like This

Use Quizgecko on...
Browser
Browser