Search by

jawira / nice-maze-generator

jawira

Create a maze using ascii art

Package info

gitlab.com/jawira/nice-maze-generator

Issues

pkg:composer/jawira/nice-maze-generator

Statistics

Installs: 19

Dependents: 0

Suggesters: 0

Stars: 0

v2.0.0 2026-09-12 15:54 UTC

This package is auto-updated.

Last update: 2026-09-12 16:00:48 UTC


README

Create mazes using ASCII art.

Latest Release coverage report pipeline status

How to install

composer require jawira/nice-maze-generator

Usage

Create a maze

Instantiate the Maze class to generate a random maze. Since this class implements \Stringable, you can directly print the $maze object.

<?php

use Jawira\NiceMazeGenerator\Maze;

$maze = new Maze(5, 20); // 5 rows and 20 columns

echo $maze;

This is the output from the previous code:

╭───────┬─────┬─────────────┬─────┬─────╮
│       │     │             │     │     │
├─────╮ ╵ ╭─╮ │ ╶─────╮ ╶─╮ ╰───╮ ╵ ╷ ╶─┤
│     │   │ │ │       │   │     │   │   │
├───╴ ├───╯ │ ├─────┬─┴─╮ ├───╮ ╰───┤ ╷ │
│     │     │ │     │   │ │   │     │ │ │
│ ╶─┬─╯ ╷ ╷ │ │ ╭─╴ │ ╷ │ │ ╷ ╰───╮ │ │ │
│   │   │ │ │ │ │   │ │ │ │ │     │ │ │ │
│ ╷ ╵ ╶─┤ ╰─╯ ╵ │ ╶─╯ │ ╵ │ │ ╶───╯ ╰─╯ │
│ │     │       │     │   │ │           │
╰─┴─────┴───────┴─────┴───┴─┴───────────╯

Access the maze array

You can access the array version of the maze via the maze property.

<?php

use Jawira\NiceMazeGenerator\Maze;

$maze = new Maze(4, 15);

foreach ($maze->maze as $row) {
    foreach ($row as $char) {
        echo $char;
    }
    echo PHP_EOL;
}

Use a Seed

Use the seed parameter to reproduce a maze.

<?php

use Jawira\NiceMazeGenerator\Maze;

$maze = new Maze(6, 18, 123); // always generates the same maze

echo $maze;

Contributing

License

This library is licensed under the MIT license.