# Run the Game of Life starting from a random grid
game_of_life <- ca_library("gameoflife")
grid <- generate_initmat(game_of_life, c(LIVE = .1, DEAD = .9), nrow = 64)
out <- run_camodel(game_of_life, grid, times = seq(0, 128))
image(out) # final configuration
# Logistic growth of plants
mod <- camodel(
transition(from = "empty", to = "plant", ~ r * p["plant"]),
transition(from = "plant", to = "empty", ~ m),
parms = list(r = 1, m = .03),
wrap = TRUE,
neighbors = 8
)
grid <- generate_initmat(mod, c(empty = .99, plant = .01), nrow = 128)
image(grid) # initial state
out <- run_camodel(mod, grid, times = seq(0, 30))
image(out) # final state
plot(out) #
Run the code above in your browser using DataLab