1000 option arithmetic integer x2 = 24 y2 = 70 dim a(x2, y2), b$(x2) print "enter your pattern:" for c=1 to size(b$) line input b$(c) if _exit then exit for next c l = 0 for x=1 to c - 1 l = max (l, len(b$(x))) next x x1 = 11 - c / 2 y1 = 33 - l / 2 for x=1 to c for y=1 to len(b$(x)) if mid(b$(x), y, 1) <> " " then a(x1 + x, y1 + y) = 1 p = p + 1 end if next y next x ! display the population do clear print at 1,1: "generation:"; g, "population:"; p; x3 = size (a, 1) y3 = size (a, 2) x4 = 1 y4 = 1 g = g + 1 for x=1 to x1 - 1 print next x for x=x1 to x2 print for y=y1 to y2 if a(x,y) = 1 then print tab(y); "*"; x3 = min (x, x3) x4 = max (x, x4) y3 = min (y, y3) y4 = max (y, y4) end if next y next x x1 = max (x3, 3) x2 = min (x4, 22) y1 = max (y3, 3) y2 = min (y4, 68) p=0 for x=x1 - 1 to x2 + 1 for y=y1 - 1 to y2 + 1 c = 0 for i=x - 1 to x + 1 for j=y - 1 to y + 1 if a(i,j) = 1 or a(i,j) = 2 then c = c + 1 end if next j next i if a(x,y) = 0 then if c = 3 then a(x,y) = 3 p = p + 1 end if else if c < 3 or c > 4 then a(x,y) = 2 else p = p + 1 end if end if next y next x x1 = x1 - 1 y1 = y1 - 1 x2 = x2 + 1 y2 = y2 + 1 for x=x1 to x2 for y=y1 to y2 select case a(x,y) case 0: case 1: case 2: a(x,y) = 0 case 3: a(x,y) = 1 end select next y next x loop