Quiz 2

📏 Heuristic Functions: Hamming & Manhattan

164 words
1 min read
Python Week 1: the first filter for runtime behavior
Visual companion
Python
Type and operator map

Python Week 1: the first filter for runtime behavior

View
Revision summary

What this note is really saying

Short form

# 📏 Heuristic Functions: Hamming & Manhattan ## 1. 🎯 Learning Objectives - Compute Hamming and Manhattan distances for the 8-puzzle - Explain why Manhattan dominates Hamming - Design admissible heuristics for other problems ## 2.

📏 Heuristic Functions: Hamming & Manhattan

1. 🎯 Learning Objectives

  • Compute Hamming and Manhattan distances for the 8-puzzle
  • Explain why Manhattan dominates Hamming
  • Design admissible heuristics for other problems

2. 📖 Core Content

3.1 Hamming Distance (Misplaced Tiles)

Count of tiles not in their goal positions (excluding the blank). State: [2,8,3][1,6,4][7,0,5] Goal: [1,2,3][8,0,4][7,6,5] Tiles not in place: 1,2,6,8? Let's count: 2≠1, 8≠2, 1≠8, 6≠0? No 6≠6? Actually check each: (0,0)=2 vs 1✗,(0,1)=8 vs 2✗,(0,2)=3 vs 3✓,(1,0)=1 vs 8✗,(1,1)=6 vs 0✗,(1,2)=4 vs 4✓,(2,0)=7 vs 7✓,(2,1)=0 vs 6✗,(2,2)=5 vs 5✓. Hamming=5.

3.2 Manhattan Distance

Sum of |x₁-x₂|+|y₁-y₂| for each tile. For tile 1: current(1,0) goal(0,0) = 1+0 = 1. Tile 2: (0,0) to (0,1) = 1. Tile 8: (0,1) to (1,0) = 2. Sum = 5.

3.3 Dominance

Manhattan ≥ Hamming for all states (every misplaced tile has Manhattan ≥ 1). A* with Manhattan never expands more nodes than A* with Hamming. Join Discord PreviousHeuristic DesignNextHill Climbing
Document outline

Keep your place and jump directly to a heading.

Table of Contents
System Normal // Awaiting Context

Intelligence Hub

Navigate the knowledge graph to generate context. The Hub adapts dynamically to surface backlinks, related notes, and metadata insights.