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

A Star Algorithm

The document provides a detailed explanation of the A* search algorithm, which is used for finding the shortest path between two nodes in a graph. It describes the algorithm's components, including cost functions, heuristic functions, and its iterative process involving open and closed lists. Additionally, it includes pseudocode for implementing the A* algorithm.

Uploaded by

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

A Star Algorithm

The document provides a detailed explanation of the A* search algorithm, which is used for finding the shortest path between two nodes in a graph. It describes the algorithm's components, including cost functions, heuristic functions, and its iterative process involving open and closed lists. Additionally, it includes pseudocode for implementing the A* algorithm.

Uploaded by

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

END OF SEMESTER ALGORITHM PROJECT

By Group IX

I. A Star Algorithm(TEGUIA Abel)

i. Definition and Description


The A* search algorithm is a widely used and efficient graph traversal algorithm for finding the
shortest path between two nodes in a graph. It combines elements of both Dijkstra's algorithm
and a heuristic function to improve efficiency by prioritizing paths that are likely to lead to the
goal.

Here's a detailed explanation of how the A* search algorithm works:

1. Graph Representation: The A* search algorithm operates on a graph, where nodes


represent locations or states, and edges represent the connections or transitions between
these locations/states. Each edge has a cost associated with it, typically representing the
distance or effort required to traverse it.
2. Cost Functions and Heuristic Function: A* utilizes two key components: a cost
function (often denoted as g(n)), which represents the cost of the path from the start node
to the current node, and a heuristic function (often denoted as h(n)), which estimates the
cost from the current node to the goal node. The evaluation function f(n) is then defined
as the sum of g(n) and h(n).
3. Process: The A* algorithm maintains two lists: an open list and a closed list. The open
list contains the nodes to be evaluated, while the closed list contains the nodes that have
already been evaluated. Initially, only the start node is in the open list.
4. Iterative Process: The algorithm repeatedly selects the node with the lowest f(n) value
from the open list. If the current node is the goal node, the algorithm terminates, and the
optimal path is obtained. Otherwise, it generates the neighboring nodes of the current
node that have not been evaluated. For each neighboring node, it calculates its g(n) value,
the cost from the start node to the neighbor node, and determines the h(n) value using the
heuristic function. If the neighbor node is not in the open list or if its f(n) value is lower
than the previously recorded value, it is added/updated in the open list with its f(n), g(n),
and h(n) values. The current node is then moved to the closed list, and the process is
repeated.
5. Backtracking: Once the goal node is reached, the optimal path can be obtained by
backtracking from the goal node to the start node, following the recorded best-parent
links.

A search algorithm efficiently explores the graph, leveraging the heuristic function to guide its
search and find the shortest path from the start node to the goal node. With its ability to consider
both actual and estimated costs, A is widely used in various applications, including pathfinding,
robotics, and artificial intelligence.
ii. Pseudocode

// A* (star) Pathfinding// Initialize both open and closed list


let the openList equal empty list of nodes
let the closedList equal empty list of nodes// Add the start node
put the startNode on the openList (leave it's f at zero)// Loop until you
find the end
while the openList is not empty // Get the current node
let the currentNode equal the node with the least f value
remove the currentNode from the openList
add the currentNode to the closedList // Found the goal
if currentNode is the goal
Congratz! You've found the end! Backtrack to get path // Generate
children
let the children of the currentNode equal the adjacent nodes

for each child in the children // Child is on the closedList


if child is in the closedList
continue to beginning of for loop // Create the f, g, and
h values
child.g = currentNode.g + distance between child and current
child.h = distance from child to end
child.f = child.g + child.h // Child is already in openList
if child.position is in the openList's nodes positions
if the child.g is higher than the openList node's g
continue to beginning of for loop // Add the child to
the openList
add the child to the openList

You might also like