CSCI-561
Fall 2010
Macskassy
Homework 2
Due Sep. 29, 2010
Student name: _____________________________
Student ID: _________________
Question 1. A* Search
(Coding assignment relevant to the Project 1)
[20 points]
In a 5*5 grid,
Start cell = Agent (A).
Goal cell = Target (T).
The black grids are obstacles, the
agent can only move in the white grids, and can only move horizontally or vertically one grid per
time, and the cost of each movement is 1. But the agent could only sense the four grids that
adjacent to its location, i.e., left, right, upper, lower. The following pictures show a sample of
such 5*5 grids and the shortest path from A to T.
Your task is to implement A* search with your own designed heuristic function that receives the
situation of the grids and outputs the shortest path of A to reach T. The input will be given in a
file named “input.txt”, please make sure your program can take the parameter when executing.
Please describe your heuristic function in this question in the submitted homework and prove
your function is admissible.
Sample Input : (where 1 refers to the white box, -1 refers the black box, A refers to the location
of agent, T refers to the location of the goal)
1
1
1
1
1
1
1
1
1
1
1
1
-1
1
1
1
1
-1
1
1
1
1
A
-1
T
Sample Output:
(0,2), (0,1), (1,1), (1,2),(1,3), (2,3),(3,3),(4,3),(4,2),(4,1),(4,0)
The output indicates the shortest path from A to T. The coordinates of left bottom is (0,0). Note