Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion Readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -64,9 +64,15 @@ const maze = generator(8, 4, false);
// Width == 8, height == 4, maze edges are closed, using random seed
const maze = generator(8, 4, true, 123456);

```
// Width == 8, height == 8, edges are open, default seed 1
// and texture == 0.9 (very horizontal maze)
const maze = generator(8, 8, false, 1, 0.9);

// Width == 8, height == 8, edges are open, default seed 1
// and texture == 0.1 (very vertical maze)
const maze = generator(8, 8, false, 1, 0.1);

```

_Note: the maze is an array of rows, so to access individual cells by their x/y
positions, you need to specify the row first. For example:
Expand Down
4 changes: 2 additions & 2 deletions src/generate-maze.ts
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ function addSetExits(row: Cell[], nextRow: Cell[], random: () => number) {
});
}

function generate(width = 8, height = width, closed = true, seed = 1) {
function generate(width = 8, height = width, closed = true, seed = 1, texture = 0.5) {
const random = mulberry32(seed);
const maze = [];
const r = range(width);
Expand All @@ -135,7 +135,7 @@ function generate(width = 8, height = width, closed = true, seed = 1) {
// All rows except last:
initial(maze).forEach((row, y) => { // TODO initial temp?
populateMissingSets(row, random);
mergeRandomSetsIn(row, random);
mergeRandomSetsIn(row, random, texture);
addSetExits(row, maze[y + 1], random);
});

Expand Down