Loading repository data…
Loading repository data…
omarlahkim / repository
🧠 Tool for solving puzzles using the most common searching algorithms: BFS, DFS, A STAR a.k.a A*, and Greedy Best First.
1 - Programming Language and Version
2 - Configuration File and other input arguments
4 - Program Testing with different puzzles
5 - Separation between what belongs to the search shell and what is puzzle specific
This program is written in Python version 3.6, however, it should run fine with recent versions of Python 3 (Tested with 3.6 and 3.8).
The project root folder contains a "Files" folder which too contains a states.json file, in this file there are some default values for initial states and goal states for all the 3 puzzles, when the program is running, these default values show up to the user to choose from.
However, for flexibility and scalability purposes, the Json file can be modified any time before running the program to add different initial states and goal states for the puzzles.
Note:
The Json file is the only external file and argument the program requires, choice of the problem, algorithm, heuristic and other inputs (depth limit…) are supplied at runtime.
In case the initial and goal states for a problem are already existing in the Json file, no modification shall happen to that file, otherwise, manually insert the initial and goal state values in the Json file before running the program.
pip3 install -r requirements.txt
4.1 Using IDE (Preferably PyCharm, because it will display the colors):
4.4 Using Terminal:
If you're familiar with the venv you can use it instead of installing the requirements by doing the following:
Note: in case of not wanting to limit the search to a number of expansions, the user must input 0 and the search will not stop until the program finishes
As shown in the figure above, which illustrates the project structure, all the search algorithms are gathered in the Algorithms folder, and the Puzzles are in the Problems folder.
However, we set up a shared folder which contains Node.py that is a parent class for the 3 Puzzles. And In order to abstract the manipulation of Problems' nodes, we implemented a Tree that provides the needed functions such as addFrontier(), executeSuccessorFunction(), addExploredNode()… the Tree also guarantees data persistency by creating single instance of the tree that holds all the attributes such as Frontiers, ExploredSet.
Tree is considered as a shared element between the SearchShell and the problems since the algorithms take a tree as an argument to manipulate the data according to the search specifications.