Giter Club home page Giter Club logo

8puzzle's Introduction

8Puzzle

Two working solution to the 8 puzzle.


TileSearch.py--

This is a breadth first search implementation of the 8-puzzle problem. It comes with a command line user interface where the user can decide to input their own state or generate a random one. The data structure is a minHeap priority queue which orders the nodes by the path-cost (i.e. the number of moves it took to get to the current state from the initial state).

I use a set containter to hold the nodes that have been visited already so that we dont waste the resources when revisiting them. I check if a state is final before I insert it into any containers for optimization purposes. This solution is my fastest one even though it is not the most efficient.


TileSearchManhattan.py--

This solution is almost the same as the BFS solution but it also uses a heuristic, called Manhattan Distance. So instead of just ordering the states by their path-cost, it combines the ordering with this Manhattan distance heuristic. The lower the Manhattan distance the closer the current state is to the goal state. Through extensive testing of various starting states, this solution takes about 2x - 5x times longer to solve and only searches about 10% less states on average.

8puzzle's People

Contributors

anton1123 avatar

Watchers

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