An R implementation of John Conway's cellular automata Game of Life.
Install the following R packages from within an active R session, e.g.
install.packages("matrixcalc")Rpackages:matrixcalc,dplyr,ggplot2,gganimate.
From within an active R session:
install.packages("devtools")
devtools::install_github("alextkalinka/gameRlife")- Use one of the in-built random seeds:
gg <- game_of_life(seed_random4,
num_gens = 70,
board_size = 50)This will produce the following animation:
- Use a random seed:
seed <- make_seed_random(board_size = 50,
proportion_living = 0.4)
gg <- game_of_life(seed,
num_gens = 100,
board_size = 50)- Define a specific seed of your own.
For example, the in-built seed_glider is a 5x2 matrix of living cell co-ordinates, with the first column specifying the row and the second column specifying the column:
> seed_glider
[,1] [,2]
[1,] 2 3
[2,] 3 4
[3,] 4 2
[4,] 4 3
[5,] 4 4
The return object of a previous game can be animated without needing to run the simulation again:
# Object 'gg' returned by the function 'game_of_life'.
animate_gol(gg)
# Just run generations 20 to 50.
animate_gol(gg, from = 20, to = 50)Please contact Alex Kalinka
Gardner, M. 1970. The fantastic combinations of John Conway's new solitaire game 'life'. Scientific American 223 (4): 120-123.
