Giter VIP home page Giter VIP logo

8_puzzle_solver_prolog's Introduction

8-puzzle solver using A* in prolog

8-puzzle

Board

In this puzzle you have 8 tiles and each tile is represented with a number from 1 to 8 and there is also an empty space.

Rules

  • You can only move tiles horizontally or vertically where there is an empty space.
  • You win when you reach the desired configuration of tiles
  • Each move will have a cost of 1

Hot to use

  • You need an interpreter to consult the program puzzle.pl. I used a program called SWI Prolog to consult my program
  • To solve an 8-puzzle you need to call the predicate solvepuzzle with the following parameters
  • First parameter is the initial state.
  • Second parameter is the goal state.
  • Third parameter is a variable called Cost that returns the total cost to reach the desired configuration.

Example

solvepuzzle([[1,3,4],[8,0,5],[7,2,6]], [[1,2,3],[8,0,4],[7,6,5]],Cost).

Output

If the puzzle is solvable it returns the total cost with each step to solve it.

If the puzzle is not solvable it returns "No soution"

Example

Test Cases

You can find additional test cases in the file called text_cases.txt

8_puzzle_solver_prolog's People

Contributors

romel309 avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar  avatar

Forkers

vandana0805

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.