Skip to content

GabrelGarcia/Puzzle8-Problem-Python

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

3 Commits
ย 
ย 
ย 
ย 

Repository files navigation

Puzzle8-Problem-Python

๐Ÿงฉ 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.

๐Ÿ“‹ Search Parameters & Problem Structure

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 set to 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.

๐Ÿ› ๏ธ Prerequisites

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).


About

Solving the Puzzle 8 Problem with BSF and DSF (Uninformed Search) from the book: "Artificial Intelligence: A Modern Approach" by Peter Norvig and Stuart Russel

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages