0% found this document useful (0 votes)
308 views4 pages

Assignment No.: Aim: Implement A Star Algorithm For Eight Puzzle Problem. Objective

i) The document discusses implementing the A* search algorithm to solve the eight puzzle problem. A* combines uniform cost search and heuristic search to efficiently find optimal solutions. ii) It explains the basic concepts of A* including the evaluation function f(n) = g(n) + h(n) where g(n) is path cost and h(n) is heuristic estimate. A* prioritizes expanding nodes with the lowest f values. iii) Implementation of A* for eight puzzles involves using OPEN and CLOSED lists to track generated and examined nodes. It provides an example of calculating heuristic values h1 and h2 for eight puzzles.

Uploaded by

Lucky Tembhurne
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
308 views4 pages

Assignment No.: Aim: Implement A Star Algorithm For Eight Puzzle Problem. Objective

i) The document discusses implementing the A* search algorithm to solve the eight puzzle problem. A* combines uniform cost search and heuristic search to efficiently find optimal solutions. ii) It explains the basic concepts of A* including the evaluation function f(n) = g(n) + h(n) where g(n) is path cost and h(n) is heuristic estimate. A* prioritizes expanding nodes with the lowest f values. iii) Implementation of A* for eight puzzles involves using OPEN and CLOSED lists to track generated and examined nodes. It provides an example of calculating heuristic values h1 and h2 for eight puzzles.

Uploaded by

Lucky Tembhurne
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
You are on page 1/ 4

Assignment No.

Aim: Implement A star algorithm for eight puzzle problem.


Objective:
Student will learn:
i)

The Basic Concepts of A Star :Evaluation function, Path Cost ,Heuristic function,
Calculation of heuristic function

ii)

General structure of eight puzzle problem.

iii)

Logic of A star implementation for eight puzzle problem.

Theory:
Introduction:
In computer science, A* (pronounced as "A star") is a computer algorithm that is widely used
in path finding and graph traversal, the process of plotting an efficiently traversable path between
multiple points, called nodes. The A* algorithm combines features of uniform-cost search and
pure heuristic search to efficiently compute optimal solutions.
A* algorithm is a best-first search algorithm in which the cost associated with a node is f(n) =
g(n) + h(n), where g(n) is the cost of the path from the initial state to node n and h(n) is the
heuristic estimate or the cost or a path from node n to a goal.
Thus, f(n) estimates the lowest total cost of any solution path going through node n. At each
point a node with lowest f value is chosen for expansion. Ties among nodes of equal f value
should be broken in favor of nodes with lower h values. The algorithm terminates when a goal is
chosen for expansion.
A* algorithm guides an optimal path to a goal if the heuristic function h(n) is admissible,
meaning it never overestimates actual cost. For example, since airline distance never

overestimates actual highway distance, and manhattan distance never overestimates actual moves
in the gliding tile.
For Puzzle, A* algorithm, using these evaluation functions, can find optimal solutions to these
problems. In addition, A* makes the most efficient use of the given heuristic function in the
following sense: among all shortest-path algorithms using the given heuristic function h(n). A*
algorithm expands the fewest number of nodes.
The main drawback of A* algorithm and indeed of any best-first search is its memory
requirement. Since at least the entire open list must be saved, A* algorithm is severely spacelimited in practice, and is no more practical than best-first search algorithm on current machines.
For example, while it can be run successfully on the eight puzzles, it exhausts available memory
in a matter of minutes on the fifteen puzzles.
A star algorithm is very good search method, but with complexity problems
To implement such a graph-search procedure, we will need to use two lists of node:
1) OPEN: nodes that have been generated and have had the heuristic function applied to them
but which have not yet been examined (i.e., had their successors generated). OPEN is actually a
priority queue in which the elements with the highest priority are those with the most promising
value of the heuristic function.
2) CLOSED: Nodes that have already been examined. We need to keep these nodes in memory
if we want to search a graph rather than a tree, since whether a node is generated, we need to
check whether it has been generated before
A * Algorithm:
1. Put the start node s on OPEN.
2. If OPEN is empty, exit with failure
3. Remove from OPEN and place on CLOSED a node n having minimum f.
4. If n is a goal node exit successfully with a solution path obtained by tracing back the
pointers from n to s.

5. Otherwise, expand n generating its children and directing pointers from each child node to
n.

For every child node n do


evaluate h(n) and compute f(n) = g(n) +h(n)= g(n)+c(n,n)
+h(n)
If n is already on OPEN or CLOSED compare its new f with the
old f and attach the lowest f to n.
put n with its f value in the right order in OPEN

6. Go to step 2.
Example of calculation of heuristic values for 8-puzzle problem:

h1(n) = number of misplaced tiles

h2(n) =no. of squares from desired location of each tile

h1(S) = 8

h2(S) = 3+1+2+2+2+3+3+2 = 18

Implementation logic for 8-puzzle problem using A* algorithm

f(n)=g(n)+h(n)
Where, f(n) is evaluation function
g(n) is path cost
h(n) is heuristic function
A* is commonly used for the common path finding problem in applications such as games, but
was originally designed as a general graph traversal algorithm.
Conclusion: A star algorithm is implemented for eight puzzle problem.

You might also like