๐งฉ 8-Puzzle Solver using Uninformed Search (BFS & DFS)
This repository contains a Python implementation to solve the classic 8-Puzzle problem. The project utilizes uninformed search algorithms โ Breadth-First Search (BFS) and Depth-First Search (DFS) โ applying core Artificial Intelligence concepts for state modeling, frontiers, and successor functions.
The code models the problem strictly following standard AI search concepts:
- Initial State: The starting configuration of the board, passed as space-separated arguments via the terminal.
- Goal State: The targeted configuration, defined by default as:
1 2 3 4 5 6 7 8 0 ``` *(Where `0` represents the empty space).* - Successor Function: Generates valid next states by moving the empty space (
0) up, down, left, or right. - Frontier (Boundary): Stores discovered nodes that are yet to be expanded. Uses a FIFO queue (
collections.deque) for BFS and a LIFO stack (standard list) for DFS. - Reached / Visited: A
setto store already explored states, preventing cycles and redundant computations. - Goal Test: Checks at each step whether the current state matches the targeted goal state.
- Inversion Counting: Includes a mathematical parity validation to check beforehand whether the provided initial state is solvable.
To run this project, you only need Python 3 installed on your system. No external libraries are required (it uses native modules: os, time, sys, and collections).