Git Product home page Git Product logo

8-puzzle-solver's Introduction

8-Puzzle-Solver

This program currently only supports the solutions for the 8-puzzle (3x3 tiles).

The program must be configured by entering the starting x, y coordinates (coordinates of the blank tile), along with the Start State and Goal State as 2D lists representing the arrangement of the respective 3x3 tiles, found at the beginning of the Main.java file.

The upper left-most tile has the coordinates (0,0), and the lower right-most tile has the coordinates (2,2).

An example of a configuration:

static final int start_x = 1;
static final int start_y = 1;

static final int[][] start_state = {
				{ 7, 2, 4 },
				{ 5, 0, 6 },
				{ 8, 3, 1 }
				};

static final int[][] goal_state = {
				{ 0, 2, 4 },
				{ 7, 3, 6 },
				{ 5, 8, 1 }
				};

Uniform Cost Search is utilized, along with the Manhattan Distance algorithm for state-cost evaluation at each step, to determine the solution for any given set of initial state and goal state. After running the program, the solution will be displayed as the sequence of actions to be executed from the initial state in order to arrive at the goal state.

Example program run with above configuration:

Solving...

7 2 4 
5 0 6 
8 3 1 

7 2 4 
5 3 6 
8 0 1 

7 2 4 
5 3 6 
0 8 1 

7 2 4 
0 3 6 
5 8 1 

0 2 4 
7 3 6 
5 8 1 

Puzzle solved.

8-puzzle-solver's People

Contributors

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