0% found this document useful (0 votes)
88 views10 pages

N-Puzzle Game Project

The document discusses solving the N-puzzle problem using the A* algorithm. The N-puzzle involves sliding numbered tiles on a board to arrange them in order, with one empty space. It can be modeled as a graph search problem. The document explains that A* is well-suited for solving N-puzzle as it is an informed search algorithm that considers path costs and estimated distance to the goal. The document then outlines the basic steps of how A* would solve N-puzzle, such as maintaining open and closed lists to efficiently search the state space graph.

Uploaded by

rayanra2003
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)
88 views10 pages

N-Puzzle Game Project

The document discusses solving the N-puzzle problem using the A* algorithm. The N-puzzle involves sliding numbered tiles on a board to arrange them in order, with one empty space. It can be modeled as a graph search problem. The document explains that A* is well-suited for solving N-puzzle as it is an informed search algorithm that considers path costs and estimated distance to the goal. The document then outlines the basic steps of how A* would solve N-puzzle, such as maintaining open and closed lists to efficiently search the state space graph.

Uploaded by

rayanra2003
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/ 10

N-Puzzle Game

Layan Alqahtani - 1914793


Ghayda Almalki - 1911101
Taef Alshakalia - 1805273
The description of N-puzzle problem
The n-puzzle problem it's more known as 8-puzzle and there is more like 15-puzzle for
advanced difficulty, the problem is where there are numbers spread in every Squire and
there one empty Squire/space that separates the numbers and confuse the numbers
present in 3 rows and 3 columns for example in 8-puzzle, and 4 rows 4 columns in 15-
puzzle, and it presents in algebra as:
(k*k-1(=n)).

The goal for this puzzle we try to make the numbers in order by specific steps like (up,
down, left, right) by moving the numbering squires through the empty space. The
problem is finding a series of moves that convert the initial state configuration into the
target state configuration.

Theoretical Background
Each thing in Artificial Intelligence (AI) follows an algorithm. There are simple and also
difficult but impressive algorithms, at the basic level. N-Puzzle supports various types of
search algorithms and is divided into two parts, the uninformed search, including:
breadth-first search and depth-first search. These algorithms don't know anything about
what they are looking for and where they should be looking for it. This is the reason
behind the search name "Uninformed search". Uninformed search takes a lot of time to
search because it doesn't know where to go and where the best chances of finding the
item are, so it wouldn't be the best solution and they worked on finding another
algorithm that would be better for solving the N-puzzle game problem. The other part is
the Informed Search, in which we will talk about the A* algorithm. In this, the algorithm is
aware of where the best chances of finding the element are and the algorithm heads that
way! Heuristic search is an informed search technique. A heuristic value tells the
algorithm which path will provide the solution as early as possible.
The Best AI Algorithm to Solve the problem
The solution for this problem has a lot of different ways of solutions but we choose and
providing the best action for this problem to measure and proceed the best path which is
by using A* algorithm, by moving the empty square/space in all directions that is possible
in a start state and for each state calculate the f-score and that is ECS which called
(expanding current state), the least f-score state it will be selected and expanded again
and it will continue that way until it achieve the goal state. A* Algorithm is a computer
algorithm and one of the best techniques used in pathfinding and graph traversal, unlike
other pathfinding algorithms, it is really a smart algorithm like it has a brain, so this
algorithm considers the best for N-puzzle problem.
The main feature of the A* Algorithm is that it is keeping a track of all visited nodes in
each, so it helps ignoring every node that is already been visited, and that saves a big
amount of time and useless data. Also, it has a list that can hold the nodes that will be
explored and choose the most optimal ones, this will save time to not exploring any
unnecessary nodes. So, A* Algorithm uses a combination of heuristic values.

Design and explain to the solution of the proposed


problem
How A* Algorithm works?
In this algorithm, the process starts by maintaining a tree of paths at the initial state, the
paths will extend one edge at a time,
And it continues until the termination criterion is satisfied.
The function that extends the path that minimizes is as follow:

F(n) = g(n) + h(n)


- n: The last node on the path.
- g(n): The cost from start node to the node “n”.
- h(n): A heuristic function to estimate the cost of the closet path from node n to the
goal node.
• A* Algorithm involves maintaining OPEN and CLOSED lists.

• The OPEN list contains those nodes that been evaluated by h(n) function but not have
been expanded yet.

• The CLOSE list contains those nodes that have been successfully visited.

So, the algorithm will goes as follow:


1. Define an OPEN list
will contain just a single node, we call it start node S.
2. If the list is empty, will return failure and exit
3. Remove the node n with the smallest of the function from
OPEN list and move it to CLOSED list.
If the node n is a goal state, will return success and exit.
4. The node n will expand
5. If any successor of n is the goal node, will return success with the solution by
tracking the path from the start node to goal node. If not, will go to the next step.
6. Apply the evaluation to each successor node.
If the node is not found in all lists, will be added to OPEN list.
7. Return to second step.
CODE:
OUTPUT:
Resources
[ 1] – 2 0 2 2 , G I T HU B - PA VL O SD A I S/ N - PU Z Z L E : A P R O G RA M TH A T SO L VE S TH E C L A S S IC N -
P U Z Z L E P RO B L E M U S IN G A * SE A RC H , G I TH U B , 17 M A Y 2 02 2

H T T P S :/ / G I T HU B .C O M / PA VL O SD A I S/ N - P U Z Z L E /# :~ : TE X T= T HE % 2 0N -
P U Z Z L E % 2 0% 2 8M O ST % 2 0P O P U L A RL Y % 2 0 KNO WN% 2 0 FO R% 2 0 T HE % 2 0 8 -
P U Z Z L E ,T HE % 2 0 A C C E P TA B L E % 2 0M O V E S% 2 0A R E % 2 0U P % 2 C % 2 0D O W N% 2C % 2 0L E F T % 2 C % 2
0RIGHT

[ 2] – 2 0 2 2, I M P L E M E N T I NG A - S TA R( A *) TO SO L VE N - PU Z Z L E , IN S I GH T I NT O
P R O G RA M M I NG A L GO R I THM S , 1 6 M A Y 20 2 2

H T T P S :/ /A L GO R IT HM S IN SI G H T .WO RD P RE S S .C O M / G R A P H - TH E O RY - 2 /A -S T A R- IN -
G E N E RA L / IM PL E M E N TI N G - A - ST A R- TO - SO L VE -N - PU Z Z L E /

[ 3] – 2 02 2 , SO L V IN G 8 - PU Z Z L E U S I N G A * A L GO RI T HM . , M E D IU M , 1 7 M A Y 2 0 2 2

H T T P S :/ /B L O G. GO O D A U D IE NC E .C O M /SO L VI N G - 8- P U Z Z L E -U SI N G-A -A L GO R I T HM -
7 B 5 0 9C 33 1 2 8 8? G I= FC B B 5 9 8 2 2 9B 7

[ 4] – 2 02 2 , 8 - PU Z Z L E SO L V IN G U S IN G T HE A * A L G O R I THM U S IN G PY T HO N A ND PY G A M E ,
C O D E P RO JE C T .C O M , 1 7 M A Y 2 0 2 2

H T T P S :/ / WW W .C O D E P RO JE C T .C O M /A R T IC L E S / 3 65 5 5 3 / 8 - PU Z Z L E -S O L VI N G- U S IN G - THE -A -
A L GO R I T HM - U S I NG - PY T HO

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy