Life: Game of Life

View source: R/life.r

LifeR Documentation

Game of Life

Description

Conway's Game of Life

Usage

Life(n.rows=40, n.cols=40, n.cycles=100, sleep.time=0.12,
 cols=c("#f0f0f0", "#2f81c1"), random=TRUE, rnd.threshold=0.3)

Arguments

n.rows

Number of rows

n.cols

Number of columns

n.cycles

Number of cycles

sleep.time

Time for pause after each cycle

cols

Main colors

random

If FALSE, runs in the interactive mode

rnd.threshold

0 empty board; 1 all squares are filled

Details

In the interactive mode (random=FALSE), left click to define or remove cells, then click on red square in the bottom left corner to start cycles. Click positions are rounded so they are not always precise.

To stop cycles, use Ctrl-C (Linux, macOS) or Esc (Windows) in the main R window.

The code was inspired by the Github gist (which is not available anymore) attributed to Vadim Vinichenko. Note that margins influence the behavior of cells, i.e., the field is not infinite as in the "classic" Game of Life.

Author(s)

Alexey Shipunov

References

Gardner M. 1970. The fantastic combinations of John Conway's new solitaire game "life". Scientific American. 223: 120–123.

Examples


Life(n.cols=10, n.rows=10, n.cycles=10, sleep.time=0.3)


shipunov documentation built on Feb. 16, 2023, 9:05 p.m.

Related to Life in shipunov...