Git Product home page Git Product logo

8-puzzle-solver's Introduction

8-Puzzle-Solver

A C-implementation solving the 8-puzzle problem using the uninformed search strategy BFS (Breadth-First Search) and heusitic search strategy A*. The goal is to empirically compare both strategies' space and time performance.

For each strategy, the program collects and outputs the following information:

  • sequence of moves corresponding to the solution (e.g. up, down, left, right)
  • total number of nodes expanded
  • total number of nodes generated
  • length of the solution path (number of moves)

Test Cases

Goal board configuration:

1 2 3
8 0 4
7 6 5

Initial board configurations:

Easy
1 3 4
8 6 2
7 0 5
Medium
2 8 1
0 4 3
7 6 5
Hard
2 8 1
4 6 3
7 5 0
Worst
5 6 7
4 0 8
3 2 1

Notes:

  • While A* performs well even on the worst case, the program crashes before the BFS function completes due to its memory-hogging nature. Tested as a 32-bit executable running on a 64-bit Windows® 7 OS with Intel® Core™ i5 and 8 GB RAM.
  • While there are 9! total number of configurations possible to input, only half of them are solvable. Read more about the solvability of certain configurations of the n-puzzle in this Wikipedia article or in this MathWorld explanation.

Compilation

On Windows, compile and run using the following commands

gcc main.c -o Solver.exe
Solver.exe

On Linux, compile and run using the following commands

gcc main.c -o Solver
./Solver

8-puzzle-solver's People

Contributors

c-collamar avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.