Generate a maze by "Clustering Method" algorithm
JavaScript HTML
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
bin
public
test
.gitignore
.travis.yml
LICENSE
README.md
index.js
package.json
testem.json

README.md

generate-maze-by-clustering

npm version Build Status

Generate a maze by "Clustering Method" algorithm

Usage

In Command Line

npm install -g generate-maze-by-clustering
generate-maze-by-clustering 20 10
#########################################
#       #   # # #   #     # # #   #     #
##### ### # # # # ### ##### # ### ### ###
#   # #   # #   #   #     #         #   #
# # # # # ##### ### # ### # # ##### ### #
# #     #   # #   #     #   #     #     #
# ####### ### # ### ### # ### # ### ### #
#   #     # #     # # # # #   #   # #   #
# # # ### # # ##### # ##### ######### # #
# # # # #   #     #   #   # #   #   # # #
##### # # ##### ### ### # # # ### ### ###
#     #     #         # # #   # #       #
### ### ####### ######### # ### ##### ###
#     #   #   #   #     #     #     # # #
# ### # ### ### # # ############### ### #
# #   #     # # #       # # #   #   #   #
# ### ##### # # ##### # # # # ### ##### #
#   #   #   #   #     #                 #
# ######### # ##### # # ### # ### ### ###
#       #     #     # #   # # #   #     #
#########################################

Usage:

generate-maze-by-clustering {square_width} {square_height}

  square_width, square_height:

    They do not mean byte length.
    If you set "3 2" then you will get the following size:

      #######
      # # # #
      #######
      # # # #
      #######

    In the "1 1" case:

      ###
      # #
      ###

In JavaScript

npm install --save generate-maze-by-clustering

Or, you can use in browser through the browserify.

var generateMaze = require('generate-maze-by-clustering');

var maze = generateMaze([20, 10]);

console.log(maze.toText());

Algorithm

I referred the following site:

http://apollon.issp.u-tokyo.ac.jp/~watanabe/tips/maze.html

The algorithm is named by "Clustering Method" (クラスタリング法) in this site, and many japanise sites too.

However, I don't know whether that's the right name.