If you have a copy of the new issue, #5 "Life", you'll have found a BBC BASIC listing on page 25 for a version of Conway's Game of Life. Here's the code again if you want to paste it into an emulator, plus a demo of the final thing in action!  

Thanks to Tom Stuart for knocking this up for us. If you like this kind of thing, you'll probably like his book, Understanding Computation.

 10 MODE 5
 20 SIZE=200
 30 COLS=1280 DIV SIZE:ROWS=1024 DIV SIZE
 40 DIM PRESENT(COLS,ROWS),FUTURE(COLS,ROWS)
 50 FOR COL=0 TO COLS-1:FOR ROW=0 TO ROWS-1
 60 FUTURE(COL,ROW)=RND(1)<0.5
 70 NEXT ROW,COL
 80 FOR COL=0 TO COLS-1:FOR ROW=0 TO ROWS-1
 90 PRESENT(COL,ROW)=FUTURE(COL,ROW)
100 IF PRESENT(COL,ROW) THEN GCOL 0,3 ELSE GCOL 0,0
110 MOVE COL*SIZE,ROW*SIZE
120 PLOT 0,0,SIZE
130 PLOT 81,SIZE,-SIZE
140 PLOT 81,0,SIZE
150 NEXT ROW,COL
160 FOR COL=0 TO COLS-1:FOR ROW=0 TO ROWS-1
170 N=0
180 FOR X=COL-1 TO COL+1:FOR Y=ROW-1 TO ROW+1
190 IF PRESENT((X+COLS) MOD COLS,(Y+ROWS) MOD ROWS) THEN N=N+1
200 NEXT Y,X
210 FUTURE(COL,ROW)=N=3 OR PRESENT(COL,ROW) AND N=4
220 NEXT ROW,COL
230 GOTO 80

"It first fills in the cells at random (lines 40-70) and then runs the rules of the game one step at a time. If you want to see a glider instead of random shapes, delete line 60 and add this line:

 75 FUTURE(1,0)=TRUE:FUTURE(2,1)=TRUE:FUTURE(0,2)=TRUE:FUTURE(1,2)=TRUE:FUTURE(2,2)=TRUE

Line 20 sets the size of each square — it’s 200 pixels by default, so the display is very chunky. You can make that smaller if you like, but obviously it’ll then run even more slowly because there will be more cells on the screen."

Posted
AuthorLeila Johnston