Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

N-Puzzle implementation with BFS, DFS, Greedy and A*

NotificationsYou must be signed in to change notification settings

Pariasrz/N-Puzzle-solver-with-Search-Algorithms

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 

Repository files navigation

N-puzzle solver with Search Algorithms including: BFS, DFS (with limited depth), Greedy and A*

There are 2 heuristics for Greedy and A* algorithms. The first one evaluates states with manhattan distance and the second one evaluates states with number of misplaced tiles.

Input

First n should be entered and then the initial state of puzzle would be a list of numbers from 0 to (n*n)-1. An example of 8-puzzle with n = 3 is:

 initial_state = [1, 8, 2, 0, 4, 3, 7, 6, 5]

Note that if you want to work with n > 3, goal should be changed in State class.

Output

Output of each search algorithm will be the puzzle solution, number of explored nodes and spent time for search.

BFS Solution is  ['Right', 'Up', 'Right', 'Down', 'Down', 'Left', 'Up', 'Right', 'Down']Number of explored nodes is  224BFS Time: 0.005887031555175781

Releases

No releases published

Packages

No packages published

Languages


[8]ページ先頭

©2009-2025 Movatter.jp