8-Puzzle problem solved using the A* search algorithm.

Overview

8-Puzzle

This program written in Java solves the 8-puzzle problem (and its natural generalizations) using the A* search algorithm.

The Problem:

The 8-puzzle is a sliding puzzle that is played on a 3-by-3 grid with 8 square tiles labeled 1 through 8, plus a blank square. The goal is to rearrange the tiles so that they are sorted by label in row-major order, using as few moves as possible. You are permitted to slide tiles either horizontally or vertically into the blank square.

My Solution:

Trought the use of the A* search algorithm applied to problem by introducing the Manhattan Distance of each tile of the puzzle i managed to find a solution. The program has also been optimized by avoiding to calculate unnecessary paths and thanks to some other minor adjustments.

How to use it:

After you compiled Solver.java you'll just have to run it specifying whitch puzzle (in the .txt format) has to be solved. What you'll see printed in your terminal is firstly the minimun number of moves that are necessary to solve the puzzle and after that all the moves in sequence, each represented by the corrisponding array version of the puzzle.
Example: java Solver puzzle.txt

For more information check the assigment description (Progetto DA1 2122.pdf) or the original source that inspired this project (https://coursera.cs.princeton.edu/algs4/assignments/8puzzle/specification.php).

(Curricular project for "Dati e Algoritmi 1" course at University of Padova, 2021/2022)

You might also like...

Blaze4D - Minecraft but with Vulkan using the Rosella engine.

Blaze4D - Minecraft but with Vulkan using the Rosella engine.

Information Blaze4D is a Fabric mod that changes Minecraft's rendering engine to use the Vulkan Graphics Library, it is currently in Early Development

Dec 30, 2022

Squaremap is a minimalistic and lightweight world map viewer for Minecraft servers, using the vanilla map rendering style

squaremap squaremap (formerly known as Pl3xMap) is a minimalistic and lightweight live world map viewer for Minecraft servers. What is squaremap If, l

Jan 3, 2023

using LWJGL to make a mini minecraft (mac also can run)

using LWJGL to make a mini minecraft (mac also can run)

MineCraft Mini Features MineCraft Lite in Java and OpenGL Physics simulation, water simulation Perlin noise algorithm to generate maps Directional flo

Jan 4, 2022

Good ol' PacMan game using Java

Good ol' PacMan game using Java

Table of contents General info Technologies Setup General info Good ol' PacMan. To play, you just need to use the arrow keys on your keyboard ◀️ ▶️ 🔼

Dec 28, 2022

DnD Plugin submission using Atlas. Plugin inspired on the TrollGUI bukkit plugin

💡 PunishGUI DnD Plugin submission using Atlas. Plugin inspired on the TrollGUI bukkit plugin 📜 Dependencies 📃 Paper 1.18 🌎 Atlas 💻 Commands /hell

Jan 19, 2022

Othello PvP (2-Player) Game Application created in Java using Swing and AWT, for playing the Othello game

Othello PvP (2-Player) Game Application created in Java using Swing and AWT, for playing the Othello game

Othello PvP (2-Player) Game Application created in Java using Swing and AWT, for playing the Othello game, a simple game that played on an 8 by 8 checkered board with 64 double-sided black and white discs. The game is easy to learn, but it takes time to master and develop winning strategies.

Feb 28, 2022

A game named TikTacToe developed using Java.

Project_TicTakToe This is a game named TikTacToe developed using Java. TIC-TAC-TOE Introduction: In this oop project , we worked on a small game calle

Jan 25, 2022

2048FX - The game 2048, built using JavaFX and Java 11

2048FX - The game 2048, built using JavaFX and Java 11

The game 2048 built using JavaFX 16 and Java 17.

Dec 28, 2022

A legacy-fabric mod that makes minecraft versions older than 1.13 run using LWJGL 3 instead of the legacy LWJGL 2

A legacy-fabric mod that makes minecraft versions older than 1.13 run using LWJGL 3 instead of the legacy LWJGL 2

A legacy-fabric mod that makes minecraft versions older than 1.13 run using LWJGL 3 instead of the legacy LWJGL 2

Dec 4, 2022
Owner
null
A set of word-based puzzle games for the CLI while you wait for the build to run

Words Words is a set of command line word-based puzzle games. Best way to spend those minutes within the CLI while your build is running ;). But Words

Madalin Ilie 7 Sep 15, 2022
Triple X is a 2D space game based on The Three-Body Problem

Triple X is a 2D space game based on The Three-Body Problem, which is the famous sci-fi novel wrote by Cixin Liu.

Frankie·Johnson 4 Feb 19, 2022
2D space game based on The Three-Body Problem

Triple X Triple X is a 2D space game based on The Three-Body Problem, which is the famous sci-fi novel wrote by Cixin Liu. In this game, you would dri

Frankie·Johnson 4 Feb 19, 2022
Prototype of Wordle solving algorithm

AWordle This time you Wordle the program. 'AWordle' stands for 'Automated Wordle' or 'Anti-Wordle', or something else I don't care what you think it i

MCUmbrella 1 Feb 5, 2022
Jetserver is a high speed nio socket based multiplayer java game server written using Netty and Mike Rettig's Jetlang.It is specifically tuned for network based multiplayer games and supports TCP and UDP network protocols.

Note New version of Jetserver is called Nadron and is in a new netty 4 branch of this same repo. JetServer is a java nio based server specifically des

Abraham Menacherry 1.2k Dec 14, 2022
A minecraft mod that allows using minecrafts structure block based test system

MC Tester Mod This mod allows using the automated structure based test system Mojang created for minecraft. The test system is only partially included

2No2Name 21 Nov 11, 2022
Headless Minecraft bot using cabaletta/baritone and 3arthqu4ke/HeadlessForge

headlessbot Headless Minecraft bot using cabaletta/baritone and 3arthqu4ke/HeadlessForge Build & Run Needs Java 8, Docker, Minecraft 1.12.2 and Forge

​ 15 Aug 27, 2022
A free mixin-based injection hacked-client for Minecraft using Minecraft Forge.

Custom LiquidBounce 1.8.9 build that aims to improve original visuals and bypasses, along with built-in ViaVersion to help you change from 1.8 to 1.17.1 without creating any other version branch.

epic group of paster 123 Jan 2, 2023
Golden Axe (1989) game implemented in java using only standard libraries (Java 2D, Swing, AWT & Java Sound API)

Golden Axe (1989) game implemented in java using only standard libraries (Java 2D, Swing, AWT & Java Sound API), so no external libraries required. Video: https://youtu.be/uevIVLNhQqs

Leo 101 Jul 21, 2022
Paper-nms-maven-plugin - A maven plugin for using NMS on paper with Mojang mappings.

paper-nms-maven-plugin A maven plugin for using NMS on paper with Mojang mappings. This plugin will both create the mapped paper dependency and instal

null 56 Dec 28, 2022