Share your code. npm Orgs help your team discover, share, and reuse code. Create a free org »

generate-maze-by-clustering

0.0.4 • Public • Published

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.

Keywords

install

npm i generate-maze-by-clustering

Downloadsweekly downloads

1

version

0.0.4

license

MIT

repository

githubgithub

last publish

collaborators

  • avatar