N-Puzzle Game Project
N-Puzzle Game Project
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.
• 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.
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