AI labs - Heuristic Search

Lab 15/11/2006

Notes: solve as many exercises as you can during the laboratory class. At the end of the class please submit the results you were able to produce:
  1. put code, and text files with the textual answers and/or input files in a single archive (tar, jar, or anything you like).
  2. Use the online submission system available here (login required).
Your submitted labs WON'T be evaluated.

Exercise 1 - The Tower of Hanoi

There are 3 pegs (A,B,C) and a tower of disks on the first one (A), with the smaller on the top and the bigger on the bottom. The purpose of the puzzle is to move the whole tower from the first peg (A) to the third (C), by moving only one disk every time and by observing not to put a bigger disk atop of a smaller one.

The Tower of Hanoi

This is one of the prototypical problems that can be solved by using a recursive algorithm; however, it can be encoded as a standard search problem. In this exercise you should use a standard search problem to find the minimal sequence of disc position (states) that ends up with all the four disks on the 3rd peg (C).

1.1

Encode the problem as a standard search problem, and define an appropriate consistent heuristic to guide the search.

1.2

Encode the problem in Java and use the A* to find the solution.



Exercise 2 - Local Search

In this exercise you're asked to implement and evaluate the behaviour of an hill climbing algorithm w.r.t. the 8-queen problem. Represent an 8-queen problem state as a list of 8 numbers, expressing the position of a queen in the corresponding column, counting from 1 and starting from the bottom left corner. For example, the state in the figure below corresponds to the list [1, 6, 2, 5, 7, 4, 8, 3].

8 queens

The successor function generates all the states obtained by moving one of the 8 queens along its column. The heuristic function you should use is the number of pairs of queens attacking each other. For example, the state in the figure has an heuristic value of 1.

2.1

Implement a hill climbing search using the algorithm described during the lecture. Choose the starting node randomly in the state space, using an uniform distribution.

2.2

Use the same algorithm to implement a Random-Restart hill climbing search. Use a maximum of 7 restarts per instance, choosing the random starting nodes with an uniform distribution on the state space.