SamH135/AI-puzzle-solver
Folders and files
| Name | Name | Last commit date | ||
|---|---|---|---|---|
Repository files navigation
Running the File:
1. make sure you have the python file (.py) and the data (.txt) file saved to your machine
2. open the terminal
3. enter the following command:
python "Your Absolute File Path to AI_8puzzle_solver.py" "Algorithm Choice" "Your Absolute File Path to data file"
- Algorithm choices = dfs, ids, astar1, astar2
- NOTE: you may experience errors from the terminal if you don't include the "" around the file paths
- NOTE: the depth of the state-space tree is set to 10, you can increase this depth to see if the agent can
solve puzzles that are arranged in a more difficult format (requires more moves and searches to reach the goal state).
- if you increase the depth too much, your machine may crash or experience errors, I suggest using Google Colab for this reason.
Example Terminal Input:
WINDOWS:
python "C:\Users\samue\PycharmProjects\CS4365 AI Projects\AI_8puzzle_solver.py" astar2 "C:\Users\samue\Downloads\input_file.txt"
MAC:
/usr/local/bin/python3 "/Users/jamie/Downloads/AI_8puzzle_solver.py" dfs "/Users/jamie/Downloads/input_file.txt"
Example Contents of Input File: 6 7 1 9 8 2 * 5 4 3
- If you don't have the data file, simply copy/paste those numbers into a .txt file
Example Output:
Initial Puzzle State:
6 7 1
8 2 *
5 4 3
Path:
6 7 1
8 2 *
5 4 3
6 7 1
8 * 2
5 4 3
6 7 1
* 8 2
5 4 3
* 7 1
6 8 2
5 4 3
7 * 1
6 8 2
5 4 3
7 8 1
6 * 2
5 4 3
Number of moves: 5
Number of states enqueued: 13