SkillAgentSearch skills...

Mazegen

Advanced maze generator written in Kotlin

Install / Use

/learn @maltaisn/Mazegen
About this skill

Quality Score

0/100

Supported Platforms

Universal

README

Maze generator

Advanced maze generator supporting many different maze types and generation algorithms, configurable in JSON. Mazes can be solved with the A* algorithm, braided, distance mapped, and exported to PNG, JPG, BMP, GIF or SVG.

Usage

Just drag-and-drop the configuration file on the .bat file or do one of these by command line:

mazegen config-file [additional-config-files...]
java -jar mazegen.jar config-file [additional-config-files...]

Download

See releases.

Maze types

Name | Geometry | Description | Examples | :--: | :------: | :---------: | :------: | Orthogonal | Orthogonal | Square cells on an orthogonal grid. | <img src="mazes\orthogonal_rb.png" width="120px"/> <img src="mazes\orthogonal_pr.png" width="120px"/> Weave orthogonal | Orthogonal | Orthogonal maze variation that allows passages to go over and under others. | <img src="mazes\weaveOrthogonal_rb.png" width="120px"/> <img src="mazes\weaveOrthogonal_ab.png" width="120px"/> Unicursal orthogonal | Orthogonal | Orthogonal maze variation with a single path spanning the entire maze, also called a labyrinth. | <img src="mazes\unicursalOrthogonal_kr.png" width="120px"/> <img src="mazes\unicursalOrthogonal_hk.png" width="120px"/> Zeta | Orthogonal | Orthogonal maze variation that allows diagonal passages. | <img src="mazes\zeta_rb.png" width="120px"/> <img src="mazes\zeta_pr.png" width="120px"/> Upsilon | Orthogonal | Octogon and square cells on an orthogonal grid. | <img src="mazes\upsilon_rb.png" width="120px"/> <img src="mazes\upsilon_wi.png" width="120px"/> Delta | Triangular | Triangle cells, the maze can be shaped like a rectangle, a triangle, a hexagon or a rhombus. | <img src="mazes\delta_rectangle_rb.png" width="120px"/> <img src="mazes\delta_triangle_rb.png" width="120px"/> <img src="mazes\delta_hexagon_rb.png" width="120px"/> <img src="mazes\delta_rhombus_rb.png" width="120px"/> Sigma | Hexagonal | Hexagon cells, the maze can be shaped like a rectangle, a triangle, a hexagon or a rhombus. | <img src="mazes\sigma_rectangle_rb.png" width="120px"/> <img src="mazes\sigma_triangle_rb.png" width="120px"/> <img src="mazes\sigma_hexagon_rb.png" width="120px"/> <img src="mazes\sigma_rhombus_rb.png" width="120px"/> Theta | Polar | Circle maze with adjustable center radius and cell subdivision parameter. | <img src="mazes\theta_rb.png" width="120px"/> <img src="mazes\theta_ab.png" width="120px"/>

Generators

Name | Supported maze types | Definition | Example | Distance map | :--: | :------------------: | :--------: | :-----: | :----------: | Aldous-Broder's | All | Performs a random walk, connecting the cells walked to if they were unvisited, until all cells are visited | <img src="mazes\orthogonal_ab.png" width="300px"/> | <img src="mazes\orthogonal_ab_distance_map.png" width="300px"/> Binary Tree | Orthogonal | Repeatedly carve passage north and east for each cell. The side bias can be changed. | <img src="mazes\orthogonal_bt.png" width="300px"/> | <img src="mazes\orthogonal_bt_distance_map.png" width="300px"/> Eller's | Orthogonal | Assign each cell of the first row to a different cell. For each row, randomly connect cells together if they are not in the same set, then carve at least one passage down for each set. | <img src="mazes\orthogonal_el.png" width="300px"/> | <img src="mazes\orthogonal_el_distance_map.png" width="300px"/> Growing Tree | All | Randomly walk around, connecting cells together, adding cells to a stack. When stuck, go back to a cell in the stack. The cell is chosen randomly between the newest, the oldest or a random cell. | <img src="mazes\orthogonal_gt.png" width="300px"/> | <img src="mazes\orthogonal_gt_distance_map.png" width="300px"/> Hunt-and-kill | All | Randomly walk around, connecting cells together. When stuck, scan the maze for an unvisited cell next to a visited cell and start again from there. | <img src="mazes\orthogonal_hk.png" width="300px"/> | <img src="mazes\orthogonal_hk_distance_map.png" width="300px"/> Kruskal's | All but zeta and weave orthogonal | Each cell start in a different set. Randomly remove walls between cells of different sets, merging their sets together. | <img src="mazes\orthogonal_kr.png" width="300px"/> | <img src="mazes\orthogonal_kr_distance_map.png" width="300px"/> Prim's | All | Starting with a random cell, add all of its unvisited neighbors to a "frontier" set, and connect it with one of them. Repeat that with a cell from the set until the maze is complete | <img src="mazes\orthogonal_pr.png" width="300px"/> | <img src="mazes\orthogonal_pr_distance_map.png" width="300px"/> Recursive Backtracker | All | Randomly walk around, connecting cells together, adding cells to a stack. When stuck, pop a cell from the stack and continue walking. | <img src="mazes\orthogonal_rb.png" width="300px"/> | <img src="mazes\orthogonal_rb_distance_map.png" width="300px"/> Recursive Division | Orthogonal | Recursively divide the maze area in two, carving a passage in the wall made. | <img src="mazes\orthogonal_rd.png" width="300px"/> | <img src="mazes\orthogonal_rd_distance_map.png" width="300px"/> Sidewinder | Orthogonal | For each cell in each row, randomly carve passage east or north | <img src="mazes\orthogonal_sw.png" width="300px"/> | <img src="mazes\orthogonal_sw_distance_map.png" width="300px"/> Wilson's | All but zeta and weave orthogonal | Similar to Aldous-Broder's. Performs a random walk until a visited cell is found. Carve the path used to get there and mark the cells as visited. Start walking again from a random cell. | <img src="mazes\orthogonal_wi.png" width="300px"/> | <img src="mazes\orthogonal_wi_distance_map.png" width="300px"/>

Distance maps

Distance maps are color maps where each color represent the minimum distance from the cell from a starting cell. Distance maps can be used to reveal the "texture" of mazes created by each algorithm (see table above). All maze types support distance maps.

The algorithm uses Dijkstra's and the current implementation runs in O(n²) so it might get very slow for mazes with over 100 000 cells.

<img src="mazes/zeta_big_distance_map.png" align="center" width="600px"/>

You can use the tool at http://gka.github.io/palettes for nice color gradients.

Configuration

The generator is configured with a JSON file. There are many attributes but most of them are optional. In fact, here's the minimal configuration file:

{"mazes": [{"size": 10}]}

This will generate a single 10x10 orthogonal maze, export it to the current path with default styling settings.

Here's another more complete example:

{
  "mazes": [
    {
      "name": "labyrinth",
      "count": 1,
      "type": "orthogonal",
      "size": 10,
      "algorithm": "aldous-broder",
      "braid": "50%",
      "openings": [["S", "S"], ["E", "E"]],
      "solve": true,
      "distanceMap": true,
      "distanceMapStart": ["S", "S"],
      "separateExport": false
    }
  ],
  "output": {
    "format": "svg",
    "path": "mazes/",
    "svgOptimization": 3,
    "svgPrecision": 2
  },
  "style": {
    "cellSize": 30,
    "backgroundColor": "#00FFFFFF",
    "color": "#000000",
    "strokeWidth": 3,
    "solutionColor": "#0000FF",
    "solutionStrokeWidth": 3,
    "strokeCap": "round",
    "distanceMapRange": "auto",
    "distanceMapColors": ["#ffffff", "#000000"],
    "antialiasing": true
  }
}

This will generate a 10x10 orthogonal maze with Aldous-Broder's algorithm, export it to mazes/labyrinth.svg in the most optimized SVG format. Maze will be solved for the top-left to the bottom-right corners. Half deadends will be removed (braid). A distance map will be generated starting from the top-left cell. Custom styling settings are used, but in this case they all match default ones.

More examples of configuration file are available at /mazes/config/.

Attributes

  • maze (required): array of maze set objects. A maze set is a group of mazes with the same properties, each with the following attributes
    • name: name of the set and of the file to be exported. Default is maze.
    • count: number of mazes to generate for this set. Default is 1.
    • type: maze type, one of orthogonal, weaveOrthogonal, unicursalOrthogonal, delta, sigma, theta, upsilon, zeta. Default is orthogonal.
    • size (required): maze size, either an integer or an object. The object can have the following attributes:
      • size: maze size. If maze takes 2 dimensions, both will be the same. For theta mazes, use radius instead.
      • width: maze width.
      • width: maze height.
      • radius: maze radius for theta maze.
      • centerRadius: center radius for theta maze. The number is the ratio between the center radius and the size of a cell. Default is 1.
      • subdivision: subdivision setting for theta maze. For example, if value is 1.5, a cell will be split in two when its size is 1.5 times the base size. Default is 1.5
      • maxWeave: maximum weave setting for weave orthogonal maze. The number is the maximum number of cells a passage can go over or under. If value is 0, the maze won't weave. Default is 1.
    • shape: maze shape for delta and sigma mazes. One of rectangle, triangle, hexagon, rhombus (parallelogram). Default is rectangle.
    • algorithm: algorithm to use for maze generation, either a string or an object. If a string, any value from ab, bt, el, gt, hk, kr, pr, rb, rd, sw, wi,aldous-broder, binary-tree, eller, growing-tree, hunt-kill, kruskal, prim, recursive-backtracker, recursive-division, sidewinder, wilson. Default is rb. If an object, it can take the following attributes:
      • name (required): algorithm name, see the values above.
View on GitHub
GitHub Stars28
CategoryDevelopment
Updated3mo ago
Forks6

Languages

Kotlin

Security Score

92/100

Audited on Jan 2, 2026

No findings