Anonymous user
One-dimensional cellular automata: Difference between revisions
One-dimensional cellular automata (view source)
Revision as of 19:34, 20 November 2009
, 14 years agono edit summary
No edit summary |
No edit summary |
||
Line 1,044:
<lang R>
set.seed(15797, kind="Mersenne-Twister")
Line 1,056 ⟶ 1,055:
offendvalue)
## List of patterns in which the cell stays alive
stayingAlive <- lapply(list(c(1,1,0),
c(0,1,0)), as.logical)
##
## map: list of length 3 logical vectors that map to patterns
## in which x stays alive
deadOrAlive <- function(x, map)
cellularAutomata <- function(x, map) {
}
deadOrAlive2string <- function(x) {
Line 1,069 ⟶ 1,073:
}
for (
universe <-
▲ apply(embed(universe, 3), 1, deadOrAlive),
▲ offendvalue)
▲ cat(format(x, width=3), deadOrAlive2string(universe), "\n")
}
</lang>
|