Assume an array of cells with an initial distribution of live and dead cells,
and imaginary cells off the end of the array having fixed values.

Cells in the next generation of the array are calculated based on the value of the cell and its left and right nearest neighbours in the current generation.

If, in the following table, a live cell is represented by 1 and a dead cell by 0 then to generate the value of the cell at a particular index in the array of cellular values you use the following table:

000 -> 0  # 
001 -> 0  #
010 -> 0  # Dies without enough neighbours
011 -> 1  # Needs one neighbour to survive
100 -> 0  #
101 -> 1  # Two neighbours giving birth
110 -> 1  # Needs one neighbour to survive
111 -> 0  # Starved to death.

DECLARE FUNCTION life$ (lastGen$)
DECLARE FUNCTION getNeighbors! (group$)
CLS
start$ = "_###_##_#_#_#_#__#__"
numGens = 10
FOR i = 0 TO numGens - 1
	PRINT "Generation"; i; ": "; start$
	start$ = life$(start$)
NEXT i
 
FUNCTION getNeighbors (group$)
		ans = 0
		IF (MID$(group$, 1, 1) = "#") THEN ans = ans + 1
		IF (MID$(group$, 3, 1) = "#") THEN ans = ans + 1
		getNeighbors = ans
END FUNCTION
 
FUNCTION life$ (lastGen$)
		newGen$ = ""
		FOR i = 1 TO LEN(lastGen$)
			neighbors = 0
			IF (i = 1) THEN 'left edge
				IF MID$(lastGen$, 2, 1) = "#" THEN
					neighbors = 1
				ELSE
					neighbors = 0
				END IF
			ELSEIF (i = LEN(lastGen$)) THEN 'right edge
				IF MID$(lastGen$, LEN(lastGen$) - 1, 1) = "#" THEN
					neighbors = 1
				ELSE
					neighbors = 0
				END IF
			ELSE 'middle
				neighbors = getNeighbors(MID$(lastGen$, i - 1, 3))
			END IF
 
			IF (neighbors = 0) THEN 'dies or stays dead with no neighbors
				newGen$ = newGen$ + "_"
			END IF
			IF (neighbors = 1) THEN 'stays with one neighbor
				newGen$ = newGen$ + MID$(lastGen$, i, 1)
			END IF
			IF (neighbors = 2) THEN 'flips with two neighbors
				IF MID$(lastGen$, i, 1) = "#" THEN
					newGen$ = newGen$ + "_"
				ELSE
					newGen$ = newGen$ + "#"
				END IF
			END IF
		NEXT i
		life$ = newGen$
END FUNCTION