# \donttest{
# Display covers of the rock/paper/scissor model as it is running
mod <- ca_library("rock-paper-scissor")
init <- generate_initmat(mod, rep(1, 3)/3, nrow = 100, ncol = 178)
ctrl <- list(custom_output_every = 1,
custom_output_fun = trace_plotter(mod, init))
run_camodel(mod, init, times = seq(0, 256), control = ctrl)
# Adjust colors of the previous example and increase speed
colors <- c("#fb8500", "#023047", "#8ecae6")
ctrl <- list(custom_output_every = 1,
custom_output_fun = trace_plotter(mod, init, fps_cap = 60, col = colors))
run_camodel(mod, init, times = seq(0, 600), control = ctrl)
# Display the vegetated to degraded cover ratio for the arid
# vegetation model.
mod <- ca_library("aridvege")
init <- generate_initmat(mod, rep(1, 3)/3, nrow = 100, ncol = 178)
ratio <- function(mat) {
mean(mat == "VEGE") / mean(mat == "DEGR")
}
ctrl <- list(custom_output_every = 1,
custom_output_fun = trace_plotter(mod, init,
fun = ratio))
run_camodel(mod, init, times = seq(0, 512), control = ctrl)
# Display ratios of cell pairs in the rock-paper-scissor model
mod <- ca_library("rock-paper-scissor")
init <- generate_initmat(mod, rep(1, 3)/3, nrow = 100, ncol = 178)
ratio <- function(mat) {
c(mean(mat == "r") / mean(mat == "p"),
mean(mat == "p") / mean(mat == "c"),
mean(mat == "c") / mean(mat == "r"))
}
ctrl <- list(custom_output_every = 1,
custom_output_fun = trace_plotter(mod, init,
fun = ratio))
run_camodel(mod, init, times = seq(0, 512), control = ctrl)
# }
Run the code above in your browser using DataLab