Giter Club home page Giter Club logo

maze-solving-and-generating's Introduction

Maze-Solving-and-Generating

This is a program I've created that generates and solves mazes using DFS and Randomized Prim's Algorithm!

After watching one numberphile video on maze solving I decided to jump in and make my own with no prior experience with mazes or algorithms. My first attempt at making a maze solver only worked in extremely specific situation so I had to do some research and look into how these kinds of things are implemented. That's when I came across DFS (Depth First Search) and Recursive Backtracking. It wasn't too long until I was able to get a basic version of that running. After it solved my small 5x5 maze that I made in GIMP I tried making some more mazes by hand, and after a while that because very tedious so I decided to look into maze generation. My first attempt was to just jump right in again with my new found knowledge of DFS. That failed miserably, but it wasn't long until I found out about Randomized Prim's Algorithm. I saw several algorithms, but this one seemed to fit my needs the most. It took quite a bit for me to get it up and running, but eventually it all came together. This is the final product!:

alt tag

For image manipulation I used Jimp, so I could create images and read individual pixels. Other than that the code was purely javascript(node to be specific)

You can see it in action here: https://www.youtube.com/watch?v=lXRH_YLfaZ4&t=4s

Algorithms Page: https://en.wikipedia.org/wiki/Maze_generation_algorithm

How To Run:

Clone the repository to the directory of your choice:

git clone https://github.com/SolarFloss/Maze-Solving-and-Generating.git

Then move into the root directory and run:

npm generate.js

Feel free to create an issue if you run into any problems.

maze-solving-and-generating's People

Stargazers

 avatar  avatar

Watchers

 avatar

maze-solving-and-generating's Issues

Image sizes

Hi again :)

I was wondering how you got your maze screenshot to be "big and clean" ?

The images we're generating are just cols x rows in pixels wide and the result is very small.
I tried the scale() jimp function which make the images bigger but it's still very blurry.

Error at runtime

Hi, trying to run your program and I get this error :

/web/maze|master ⇒  node index.js 
Rows & Colums(odd number pls): 5
Maze Generated: 3.309ms

/web/maze/generate.js:202
    solver("./output/new_maze.png");
    ^

TypeError: solver is not a function
    at create (/web/maze/generate.js:202:5)
    at create (/web/maze/generate.js:196:5)
    at create (/web/maze/generate.js:196:5)
    at create (/web/maze/generate.js:196:5)
    at create (/web/maze/generate.js:196:5)
    at create (/web/maze/generate.js:196:5)
    at create (/web/maze/generate.js:196:5)
    at create (/web/maze/generate.js:196:5)
    at create (/web/maze/generate.js:196:5)
    at create (/web/maze/generate.js:196:5)

I'm not familiar at all with node. I also tried :

/web/maze|master ⇒  npm install
npm notice created a lockfile as package-lock.json. You should commit this file.
npm WARN [email protected] No repository field.

removed 1 package in 0.42s

Seems like I'm doing something wrong here, could you help me please?
I'm using Node v8.9.1 on Debian 9

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.