-
Notifications
You must be signed in to change notification settings - Fork 0
This repository implements state-space trees and 3 different search algorithms to solve the classic 8-puzzle problem. The puzzle is represented as a 3x3 board with tiles numbered 1-8 and a blank space. The goal is to rearrange the tiles to match a specific goal state using only allowed moves (sliding a tile into the blank space).
SamH135/AI-puzzle-solver
Folders and files
| Name | Name | Last commit message | 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
About
This repository implements state-space trees and 3 different search algorithms to solve the classic 8-puzzle problem. The puzzle is represented as a 3x3 board with tiles numbered 1-8 and a blank space. The goal is to rearrange the tiles to match a specific goal state using only allowed moves (sliding a tile into the blank space).
Resources
Stars
Watchers
Forks
Releases
No releases published
Packages 0
No packages published