Code Monkey home page Code Monkey logo

maze-visual's Introduction

Maze Backtracking Visualization

Maze solver using backtracking algorithm

The Maze Backtracking Visualization is created using the Quad Engine

The program takes in a 2D array of map data and uses it to visualize the maze. This solver uses a Stack based backtracking algorithm to solve the maze. For more information on backtracking , see below.

Maze Classes

  • Maze

  • Reads file and implements values into 2D array of data
  • Holds locations of Entry of maze and Exit of maze
  • Renders map data to the screen
  • Maze Location

  • Holds information of Row and Column of map
  • Holds information of isWall
  • Maze Solver

  • Implements backtracking algorithm

Backtracking Algorithm

Backtracking is a general algorithm for finding all solutions to some computational problems, notably constraint satisfaction problems, that incrementally builds candidates to the solutions, and abandons a candidate as soon as it determines that the candidate cannot possibly be completed to a valid solution.

In this program I used a stack based backtracking algorithm where I keep track of visited locations on the maze and for every non visited location I check whether it is possible to move in one of the four directions.

Keep track of locations visited so far with a 2D-boolean array Push the start location onto a new stack While (the stack is not empty && stack top is not the finish location) Use the location at the top of the stack as the current location Mark the current location as visited If there is an unvisited location next to the current location Push the unvisited location onto stack, and continue the loop Else Pop the stack (i.e., remove current location as it is top of stack If stack is empty There is no path from start to finish Else Stack contains path from finish to end


maze-visual's People

Contributors

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