Algorithm for Life One Generation Shown |
1. for i <- 1 to 100 1. for j <- 1 to 100 1. s <- 0 2. for p <- i - 1 to i + 1 /compute effect for q <- j - 1 to j+ 1 /of neighbors s <- s - L(p, q) 3. s <- s - L(i, j) 4. if (s = 3) or (s - L(i, j) = 3) then X(i, j) = 1 /store life or death else X(i, j) = 0 /in auxillary array X 2. for i <- 1 to 100 1. for j <- 1 to 100 1. L(i, j) <- X(i, j) /refresh L 2. display L(i, j) /display L |
|
|