maze: Random Mazes

Description Usage Arguments Details Value Examples

View source: R/maze.R

Description

Functions for producing and identifying procedurally generated random mazes.

Usage

1
2
3
4
5

Arguments

nrow

Number of rows.

ncol

Number of columns.

x

A matrix-like object to be made into a maze (for as.maze), or an object to be identified as either a maze or not (for is.maze)

Details

For as.maze, if x is a binary matrix (or otherwise contains only two unique values), the maze will be constrained to occupy only those cells containing a 1 (the higher value).

Value

For maze and as.maze, an object of class maze, which is a subclass of matrix.

For is.maze a logical value indicating if the input is a valid maze.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
maze(10,10)
mat <- matrix(NA, 10, 10)
is.maze(mat)
m <- as.maze(mat)
is.maze(mat)

# circular maze
mat <- matrix(1, 30, 30)
for(i in 1:nrow(mat)){
    for(j in 1:ncol(mat)){
        if((i-15.5)^2+(j-15.5)^2 > 220){
            mat[i,j] <- 0
        }
    }
}
m <- as.maze(mat)

mazing documentation built on Oct. 6, 2021, 1:09 a.m.