AI Lesson 6 – Informed & Uninformed Search | Dataplexa

Informed and Uninformed Search

Intelligent agents often need to find a solution by exploring multiple possibilities. The way an agent explores these possibilities is called a search strategy.

Search is at the heart of Artificial Intelligence. Whether it is finding the shortest route, solving a puzzle, or planning actions, AI systems rely on search techniques to decide what to do next.

Why Search Is Needed in AI

In many real-world problems, the agent does not know the solution immediately. Instead, it must explore different states until it reaches a goal.

Examples include:

  • Google Maps finding the best route to your destination
  • A chess engine evaluating possible moves
  • A robot navigating through obstacles
  • An AI planner deciding the order of tasks

Search algorithms help agents explore efficiently rather than trying every possible option blindly.

Uninformed Search

Uninformed search (also called blind search) explores the search space without any additional knowledge about the goal.

The agent does not know which path is better. It simply explores systematically until it finds a solution.

Common uninformed search techniques include:

  • Breadth-First Search (BFS)
  • Depth-First Search (DFS)
  • Uniform Cost Search

These methods guarantee correctness but can be slow and memory-intensive for large problems.

Real-World Example (Uninformed Search)

Imagine searching for a lost file by opening folders one by one without knowing where it is stored. You eventually find it, but the process may take time.

Implementing a Simple Uninformed Search (DFS)

Below is a simplified Depth-First Search example using Python.


def dfs(graph, start, visited=None):
    if visited is None:
        visited = set()

    visited.add(start)
    print(start)

    for neighbor in graph[start]:
        if neighbor not in visited:
            dfs(graph, neighbor, visited)

graph = {
    'A': ['B', 'C'],
    'B': ['D', 'E'],
    'C': ['F'],
    'D': [],
    'E': [],
    'F': []
}

dfs(graph, 'A')
  
A B D E C F

Code Explanation

This code represents a graph where nodes are connected to each other.

  • The function starts at node A
  • It explores one path fully before backtracking
  • The visited set prevents infinite loops

Output Explanation

The output shows the order in which nodes are visited. DFS goes deep into one branch before exploring others, which is why node D is visited before C.

Informed Search

Informed search uses additional knowledge (heuristics) to guide the search process.

A heuristic is an estimate of how close a state is to the goal.

Instead of exploring blindly, the agent chooses paths that appear more promising.

Common informed search techniques include:

  • Greedy Best-First Search
  • A* Search

Real-World Example (Informed Search)

When Google Maps suggests a route, it does not try every road. It uses distance, traffic, and estimated time as heuristics to guide the search.

Implementing a Simple Informed Search Idea

Below is a simple heuristic-based decision example.


def choose_path(paths):
    return min(paths, key=lambda x: x['estimated_cost'])

paths = [
    {'path': 'Route A', 'estimated_cost': 10},
    {'path': 'Route B', 'estimated_cost': 5},
    {'path': 'Route C', 'estimated_cost': 8}
]

best_path = choose_path(paths)
print(best_path['path'])
  
Route B

Code Explanation

Each path has an estimated cost provided by a heuristic.

  • The agent compares estimated costs
  • It selects the path with the lowest value
  • This avoids unnecessary exploration

Output Explanation

The output shows that Route B is selected because it has the lowest estimated cost. This demonstrates how informed search improves efficiency.

Key Differences Between Informed and Uninformed Search

  • Uninformed search explores without guidance
  • Informed search uses heuristics to make better decisions
  • Informed search is usually faster and more efficient

Understanding these search strategies is essential because they form the foundation of planning algorithms, game AI, robotics, and reinforcement learning.