Giter Site home page Giter Site logo

lindelani-3 / 15puzzlesearch Goto Github PK

View Code? Open in Web Editor NEW
0.0 1.0 0.0 1.05 MB

The aim of this project was to implement, test and analyze different searching algorithms. Namely, Breadth-First Search, A* Search, and another A* Search with the Manhattan Distance heuristic. Tools used include Excel and C++.

C++ 100.00%

15puzzlesearch's Introduction

15 Puzzle Game Search

Gameplay

The 15-Puzzle is a game in which a player must slide tiles around on a 4 ร— 4 grid to reach a goal configuration. If you have never played before, I recommend trying it out here: https://15puzzle.netlify.app/.

There is one empty space that an adjacent tile can be slid into. An alternative (and simpler) view is that we are simply moving the blank square around the grid. Not all actions can be used at all times; for example, the blank tile cannot be shifted up if it is already on the top row!

The transition below illustrates the blank tile being moved to the right.

puzzle-example

Above Figure: Starting in configuration (a), the agent executes the action right. This moves the blank tile to the right, exchanging its position with F, as seen in (b). The cost of each move is 1 and the goal of the game is to slide the tiles around to reach some goal configuration, which we will take to be the letters in alphabetical order, with the bottom right corner housing the blank slot.

Problem Structure:

Input consists of a single string of characters and the hash symbol. The position of the characters in the string is its location on the board, starting from top-left and moving to bottom right. The hash represents the blank space. For example, the string ABEHCD#FGILMJKON.

Objective: Obtain shortest path from the initial state to the goal state

Initial State: Input position string

States: All possible valid position strings

Actions: [Left, Right, Up, Down]

Goal: End Game string ABCDEFGHIJKLMNO#

Search Algorithms

Breadth-First Search

A* Search H1 (Misplaced Tiles Heuristic)

A* Search H2 (Manhattan Distance)

Findings

analysis-prev

As expected, the Breadth First Search algorithm seemed to have expanded the most nodes in it's traversal through the search tree for a solution. The heuristic searches were able to look through way fewer states in comparison.

15puzzlesearch's People

Contributors

lindelani-3 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.