Displaying 1 result from an estimated 1 matches for "makemaze".
Did you mean:
makemaker
2008 Apr 29
1
A Maze Generator
...="", axes=FALSE,
...)
segments(1, -1:-(N+1) , N+1, -1:-(N+1), lwd=lwd)
segments(1:(N+1), -1, 1:(N+1), -(N+1), lwd=lwd)
segments(x+(z==4), y+(z==3), x+(z!=2), y+(z!=1), col="white",
lwd=lwd)
if (text) text(x+0.5, y+0.5, z)
rect(1, -1, N+1, -(N+1), lwd=lwd)
}
makeMaze <- function(N, p=1) { # large 'p' may result in more order
plots
z <- matrix(NA+0, N, N)
s <- function(x) if (length(x)==1) x else sample(x, size=1)
z[s(1:length(z))] <- 0
while (any(is.na(z))) {
xx <- list(z[c(2:N, N),],
z[,c(1, 1:(...