Git Product home page Git Product logo

mazesolver's Introduction

Maze Solver

The purpose of this project is to write a maze solving algorithm, but in an Unconventional way. This project tries to make the process more interative. The program is capable of identifying the path from entrance to exit for any maze of the type described. So whats different ? Any conventional program can do that. The difference is:

This program is made for the browser, not for the console :)

This program will give a step by step explanation of what is going on, with interactive events at every node of the maze. And the best part is, it does not just solve the maze and print the final output, it also display the traversal of blocked/unsuccessful paths one by one.

Exited ? Have a look !!

 

The Problem

Follow the above link, there the problem is explained properly with examples
Maze Solver: Consider a 5x5 grid maze, with a positive integer co-ordinate system and the point [0,0] located in the bottom left corner. Points are specified in [x,y] format. The grid has an entrance at position [0,1] and an exit at position [4,3]. All mazes have a core definition as above. In addition, internal dividers can be described within the grid using the format [x,y]:[x',y'] to specify start and end points. Multiple dividers can be specified in semi-colon delimited format. Write a tested program capable of identifying the path from entrance to exit for any maze of the type described above. If the maze can be solved, the program should output a valid path from entrance to exit (any valid path is equally good) else it should output the string 'blocked'.

 

The Solution Design Guide

We will be using the wall follower algorithm, the left-hand rule. The given example suggests the approach of direction based motion in order of top, right, bottom, left. We need to traverse from entry to exit point, any path is equally good. Now starting from entry point, we will check each node for its adjacent nodes. First we will check the node just above of current node, then the just right node, then the just below node and lastly the just left node. The adjacent nodes are checked with all the conditions, if we can move to it or not. If yes, we move to the first adjacent node fulfiling these conditions and buffer the other adjacent nodes as other open options for future use. We keep on repeting these steps untill we reach the exit point.
If from a node, there is no next open option, it means the current path is blocked. Now we need to try a new path. The new path should start from the latest node which have other open options. Start the reverse checking of the traversed queue, stop at the node which have other open options. Now step to the other open node and discard the unseful part of old queue. From this new node restart the normal traversal. If all the nodes have been traversed and in the reverse checking, travelled queue got empty, it means we do not have a slotion for the current maze.

 

The Code ( app.js )

Why Javascript ? Javascript gives the ability to render an animated traversal with auto increment of nodes step by step. Using object oriented js, like a program in any convetional language, I have tried to utilize the concepts of data structures. Like classes, objects, properties, methods, queues, stacks, memory utilization, garbage prevention, reverse traversal, nearest point and many other things, all are in there.

More Exited ? Go ahead, Have a look !!

 

Next Milestone

Make size, entry and exit points of the maze flexible. The support is already in there, just need to add input boxes to get user entry and use the values.

 

Contributers
  1. utsavdevsharma

 
  Last Updated: 23rd January 2014

mazesolver's People

Contributors

utsavdevsharma avatar

Watchers

James Cloos 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.