Skip to content

Metinagan/8Puzzle_AStar_Python_Solution

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

21 Commits
 
 
 
 

Repository files navigation

8-Puzzle_A-_Python_Solution

metinagan

#initial matrix

#end matrix

#Hamming value calculation

#Mannathen value calculation.

#distance of the indexes of the current matrix to where they should be in the ending matrix.

#Subtraction must be done with absolute value.

#Because: If the element that should be at position [2][2] is at position [0][0], the distance gives a negative result.

#Heuristic value is the sum of mannathen and hamming values.

#heuristic value intuitively represents our distance from the outcome.

#Returns the row and column containing element 0 in the matrix

#Adds to the list the places where the number 0 can move within the matrix

#clears the list before each step

#The function requires a matrix, row and column as values.

#If newly created matrices already exist, we do not add them to the list.

#This way we don't go through the same step again.

#and the function does not stay in an infinite loop

#We print the matrix.

#We give 2 seconds of sleep time. Because the matrixs flow so fast.

#Sıfır sayısının gidebileceği yere sıfır sayısını alıyoruz.

#Adds the new matrices we created to the list.

#This function creates matrices which will be one of our next steps.

#A-Star Algorithm

#Clear main list and add starting matrix to the end of the list

#Finally send the last element of the main list to the function