AI Search
Lesson 4 of 12
33%
Free Section Starter (Lesson 4)
PYTHON Free Section Starter Challenge 20 min

4. Heuristic Evaluation: Manhattan & Euclidean Metrics

Overview: Calculate domain-specific heuristic distances to guide search toward goal states.

Concept & Syntax Guide

A heuristic $h(n)$ estimates the cost of the cheapest path from node $n$ to a goal. For grid-based search where only orthogonal movements are permitted, the Manhattan Distance $h(n) = |x_1 - x_2| + |y_1 - y_2|$ is strictly admissible and never overestimates the true remaining cost.

Hands-On Practice Exercise

Calculate Manhattan Distance Heuristic

Compute the Manhattan distance between current state (1, 2) and goal state (4, 5).

Target Output: Manhattan Heuristic Value: 6
Need a hint? Click here to reveal
Hint: Check syntax carefully and make sure your code contains: Manhattan Heuristic Value: 6
PYTHON Code Editor
1
2
3
4
5
6
7
8
9
10