You are on page 1of 4

Andrew Emrazian – u0349111

CS 4300 - AI
Sep 7, 2016

Assignment A2: Problem Solving - Search


1. Introduction

This assignment studies statistics of using variations of A∗ search on the Wumpus World
problem. The measure of complexity is the total number of nodes generated during a search; this
means that when a node is expanded, all its children are added to the tree (unless their state has
already been created). A∗ search uses the heuristic of Manhattan distance between the current
state and the goal state. This program compares two ways to insert nodes into the priority queue
for the frontier: (1) insert before greater than or equal cost states, (2) insert after less than or
equal cost states. 2000 trials using random boards with Wumpus and 20% probability of a pit in
each (non-start) cell. Is the option 1 A∗ search 10% better than option 2 at the 95 % confidence
level. What is the mean number of search tree nodes produced by A* options 1 and 2?

2. Method
I have 9 Matlab function files that for assignment 2

1. CS4300_gen_board.m
This function is borrowed from assignment 1, which randomly sets a pit in all open cells
at a given probability.
2. CS4300_get_board_cell.m
This is a simple function that convert the coordinates for a matrix in Matlab in to
Cartesian coordinates.
3. CS4300_hueristic.m
This finds the Manhattan distance from the current grid cell to the goal grid cell.
4. CS4300_run_A_star.m
This is the driver function of A*. It runs A* a given number of times and returns the state
of each trial with option1 and option 2 discussed above.
5. CS4300_Wumpus_A_star1.m
The A* algorithm for Wumpus World. Most of the logic for this function was provided
by the instructor for this function.
6. CS4300_Wumpus_new_state.m
Determines if the state is already in the tree.
7. CS4300_Wumpus_solution.m
Determines if the current position (x,y) is the same (x,y) as the goal state.
8. CS4300_Wumpus_traceback.m
A trace from the goal state back to the starting state.
9. CS4300_Wumpus_transition.m
Determines which state the next move on the board will be.

1
The Main program can be run with the command:
[o1_c, o2_c] = CS4300_run_A_star(2000);

Some implementation details include: Children nodes are checked to see if the state that they
represent already exists in the tree structure. Each node is checked to see if it a solution
immediately after it is dequeued from the priority queue.

3. Verification of Program
I worked out the following board:

G P
P
W

Option 1

[1,1,0]

[1,1,3] [1,1,1]

[1,2,1] [1,1,2]

[1,3,1] [1,2,0] [1,2,2]

Running this in Matlab Produces a similar result. 8 Nodes are in the tree when the
solution is found.

Option 2

[1,1,0]

[1,1,3] [1,1,1]

[1,1,2] [1,2,1
]

[1,3,1] [1,2,0] [1,2,2]

2
Running this in Matlab Produces a result that was close. By hand, I found 8 nodes that
are in the tree when the solution is found but my Matlab run shows that there are 9 nodes
in the tree.

Also, with a probability 20% means that we are expected to have 3 pits per board. With
the constraint that cell (1,1) is always open, there is much higher probability for
solutions.

4. Data and Analysis

5. Interpretation

My results show that option 1 is much more efficient in terms of space complexity. The
trace back for the solution is much shorter most of the time.

6. Critique

3
It was interesting to see the contrasting statistical numbers for option 1 and option 2. They have
they same amount of solvable boards but option 1 is much more space efficient.

7. Log

I also spent about 4 hours generating data and writing up the lab report.
I spent about 14 hours coding the assignment.
18 hours in total

You might also like