GithubHelp home page GithubHelp logo

pmarchi / amaze Goto Github PK

View Code? Open in Web Editor NEW
3.0 2.0 0.0 287 KB

A maze generator inspired by the book of Jamis Buck, Mazes for Programmers: Code Your Own Twisty Little Passages.

License: MIT License

Ruby 99.87% Shell 0.13%

amaze's Introduction

Gem Version

Amaze

Amaze is both a ruby library and a command line tool to generate mazes.

I love mazes. The beauty of mazes have always fascinated me. Amaze is a personal project to create mazes with different tesselations, shapes and sizes. The wonderful book of Jamis Buck, Mazes for Programmers: Code Your Own Twisty Little Passages was a great source of inspiration. To adapt the ideas, the code and add my own little twists was a lot of fun.

Visit Think Labyrinth: Maze Algorithms if you want to explore more on mazes, their classification, creation and solving algorithms.

Installation

Amaze depends on RMagick to generate png images. RMagick is an interface between the Ruby programming language and the ImageMagick image processing library. You have to install imagemagick first before installing amaze.

On OS X install imagemagick with brew

$ brew install imagemagick

On Ubuntu

$ sudo apt-get install libmagickwand-dev

Then run

$ gem install amaze

Amaze has been tested on OS X 10.11.x and Ubuntu 16.04 with ruby 2.3.x.

Usage

Execute amaze --help for a short description of all supported options.

Generate a simple ASCII maze

$ amaze

+---+---+---+---+
|               |
+   +---+   +---+
|       |       |
+   +---+---+   +
|   |           |
+   +   +---+   +
|   |   |       |
+---+---+---+---+
Growing tree (last from list) algorithm: 0.00012327899457886815s
Dead ends: 5 of 16 (31%)
Random seed: 130944739226911434163498228124148718585

Make it a little bigger

$ amaze -g 12

How about a sigma grid

$ amaze --type sigma

 ___     ___
/   \___/   \___
\        ___    \
/   \___/    ___/
\   /    ___/   \
/   \   /   \   /
\   /   \       \
/   \___/   \   /
\___     ___/   \
    \___/   \___/
Growing tree (last from list) algorithm: 0.00015847600298002362s
Dead ends: 3 of 16 (18%)
Random seed: 210159208462445383832077802753403683598

Want to visualize the longest path through the maze (it will be nicely colored in your terminal)

$ exe/amaze --longest

+---+---+---+---+
| ∙ | ∙-------∙ |
+ | + | +---+ | +
| | | ∙---∙ | ∙ |
+ | +---+ | +---+
| ∙---∙ | ∙---∙ |
+---+ | +---+ | +
|     ∙-------∙ |
+---+---+---+---+
Growing tree (last from list) algorithm: 0.00013193400809541345s
Dead ends: 3 of 16 (18%)
Path length: 14
Random seed: 21088416182148741326253564379123099432

How about watching the algorithm doing its work?

$ amaze --visualize

Watching the alogorithm generating a maze

You can choose between different algorithm (try Hunt and Kill next)

$ amaze --visualize --algorithm hk

Finally you can render your maze as PNG

$ amaze --format=image
Growing tree (last from list) algorithm: 0.00013603299157693982s
Dead ends: 3 of 16 (18%)
Random seed: 72618483828743227022428199116847991100
Maze 'maze.png' saved.

... and a last example

$ amaze --type ortho -g 12 --format image --distances --longest

will render something like this:

Image of an ortho maze with color coded distances and longest path

Amaze has a lot more options to play with. Have fun and create beautiful pieces of algorithmic art.

Contributing

Bug reports and pull requests are welcome on GitHub at https://github.com/pmarchi/amaze.

License

The gem is available as open source under the terms of the MIT License.

amaze's People

Contributors

pmarchi avatar

Stargazers

 avatar  avatar  avatar

Watchers

 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.