maze {mazing}R Documentation

Random Mazes

Description

Functions for producing and identifying procedurally generated random mazes.

Usage

maze(nrow, ncol)

is.maze(x)

as.maze(x)

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

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)


[Package mazing version 1.0.5 Index]