2079 1

BIT252 ยท 2079 ยท 10 marks

Justify that AI can't exist without searching? Solve the following 8 puzzle problem using Hill climbing search algorithm. **Initial State:** **Goal State:**

Justify that AI can't exist without searching? Solve the following 8 puzzle problem using Hill climbing search algorithm.

Initial State: $$\begin{array}{|c|c|c|}\hline 1 & 2 & 4 \ \hline 5 & & 7 \ \hline 3 & 6 & 8 \ \hline\end{array}$$

Goal State: $$\begin{array}{|c|c|c|}\hline 1 & 4 & 7 \ \hline 2 & 5 & 8 \ \hline 3 & 6 & \ \hline\end{array}$$

[10]

Artificial IntelligenceChapter 3: Search Algorithms and TechniquesHill climbing searchNumerical: 8 puzzle hill climbing search

AI Cannot Exist Without Searching + Hill Climbing on 8-Puzzle

Part 1: Justify That AI Cannot Exist Without Searching (4 marks)

Search is the process of systematically exploring a state space to find a sequence of actions leading from an initial state to a goal state.

Justification:

  1. Problem formulation is universal in AI. Almost every AI problem is formulated as an initial state, a set of actions, a transition model, a goal test, and a path cost. Solving it means finding a path, which is search.

  2. Intelligence requires choosing among alternatives. An intelligent agent faces many possible states and actions. Selecting the right action toward a goal inherently requires exploring alternatives, that is, searching.

  3. Without search only two options remain, both non-intelligent:

    • Acting randomly (not rational), or
    • Using a fixed hardcoded response (not general, not adaptive).
  4. All major AI subfields rely on search:

AI TaskRole of Search
Problem solvingExplore action sequences to reach goal
Game playingSearch move/counter-move trees (Minimax)
Path finding, roboticsFind route from start to destination
PlanningSearch for a valid plan
Machine learningGradient descent searches a hypothesis/parameter space
Theorem provingSearch inference chains

Conclusion: Whether uninformed (BFS, DFS), informed (A*, Hill Climbing), or adversarial (Minimax), every intelligent behavior reduces to navigating a problem space. Hence AI cannot exist without searching.


Part 2: 8-Puzzle Using Hill Climbing (6 marks)

Given Data

Initial State

1 2 4
5 _ 7
3 6 8

Goal State

1 4 7
2 5 8
3 6 _

Heuristic: number of misplaced tiles $h(n)$ (blank excluded). Hill Climbing moves to a neighbor with lower $h$.

Goal Positions (row, col)

TileGoalTileGoalTileGoal
1(0,0)4(0,1)7(0,2)
2(1,0)5(1,1)8(1,2)
3(2,0)6(2,1)blank(2,2)

Step 0: Evaluate Initial State

1 2 4
5 _ 7
3 6 8
TileCurrentGoalMisplaced?
1(0,0)(0,0)No
2(0,1)(1,0)Yes
4(0,2)(0,1)Yes
5(1,0)(1,1)Yes
7(1,2)(0,2)Yes
3(2,0)(2,0)No
6(2,1)(2,1)No
8(2,2)(1,2)Yes

$$h(\text{initial}) = 5$$


Step 1: Generate Successors (blank at (1,1))

UP (swap blank with 2):

1 _ 4
5 2 7
3 6 8

Misplaced: 4, 5, 2, 7, 8 โ†’ $h = 5$

DOWN (swap blank with 6):

1 2 4
5 6 7
3 _ 8

Misplaced: 2, 4, 5, 6, 7, 8 โ†’ $h = 6$

LEFT (swap blank with 5):

1 2 4
_ 5 7
3 6 8

Misplaced: 2, 4, 7, 8 โ†’ $h = 4$ โœ“ (5 now correct at (1,1))

RIGHT (swap blank with 7):

1 2 4
5 7 _
3 6 8

Misplaced: 2, 4, 5, 7, 8 โ†’ $h = 5$

Best successor: LEFT, with $h = 4 < 5$. Move there.


Step 2: Current State $h = 4$ (blank at (1,0))

1 2 4
_ 5 7
3 6 8

Successors:

UP (swap with 1):

_ 2 4
1 5 7
3 6 8

Misplaced: 1, 2, 4, 7, 8 โ†’ $h = 5$

DOWN (swap with 3):

1 2 4
3 5 7
_ 6 8

Misplaced: 2, 4, 3, 7, 8 โ†’ $h = 5$

RIGHT (swap with 5, returns toward previous):

1 2 4
5 _ 7
3 6 8

$h = 5$ (the initial state)

Best successor $h = 5$, but current $h = 4$.

Since no neighbor improves on $h = 4$ (all are $\geq 5$), Hill Climbing halts here.


Result

Hill Climbing gets stuck at:

1 2 4
_ 5 7
3 6 8       h = 4

This is a local minimum (also a plateau/ridge situation): every move increases $h$. Therefore plain (steepest-ascent) Hill Climbing fails to reach the goal for this puzzle.

Why it fails: Hill Climbing is greedy and has no backtracking. When it reaches a state whose neighbors are all worse, it stops even though the global goal ($h=0$) is not reached. To escape, one would use techniques such as:

  • Random-restart Hill Climbing
  • Simulated Annealing
  • Stochastic / sideways moves
  • Or a complete search like A* with Manhattan distance.

Final answer: Using number-of-misplaced-tiles heuristic, Hill Climbing improves from $h=5$ to $h=4$ then gets stuck at a local minimum and cannot reach the goal state.

Short on time? The 1, 5 and 10 mark versions of this answer, flashcards and practice sets come with a program pass.