liferules: The Game of Life rules.

Description Usage Arguments Details Value Author(s) Examples

View source: R/gol.R

Description

The set of rules for the Game of Life.

Usage

1
liferules(lraster, nearNA=F)

Arguments

lraster

A raster where living and dead cells are processed.

nearNA

If TRUE, then alive cells near NSs (ocean) live forever.

Details

This function accepts a raster with ones and zeros (alive and dead cells) and processes each living cell accordingly to the original rules. However, since the raster is not and infinite plane, living cells at the edge of the raster are eliminated. If a cell has an NA neighbor, and if nearNA is set to TRUE, then that cell lives forever.

Value

A raster representing the alive/dead cells in the following generation.

Author(s)

Pedro Tarroso

Examples

1
2
3
4
5
	require(raster)
	map <- raster(ncol=360, nrow=180)
	gen0 <- prepareGrid(map)
	gen1 <- liferules(lraster)
	plot(stack(gen0, gen1))

ptarroso/gameR documentation built on Nov. 17, 2021, 12:33 a.m.