The program uses some sort of speed optimization selecting in advance and on the same loop which cells to evaluate or not.
I am not a professional programmer, not even an informatics related professional, sometimes I just code for fun as I did 35 years ago. And this was fun, and stressful at the same time ..
I was stuck at 11 lines many times (some times there were 18 ).. and had to rewrite it several times to work around how to perform several tasks on a single line..
I am happy with the results.. deppendin on the initial pattern on line 20 it can take from 30" to over a minute per generation. You can modify it to test different ones as the found at https://en.m.wikipedia.org/wiki/Conway%27s_Game_of_Life
It only uses the upper half of the screen just to speed up the action.
Ofcourse it can be further optimized for speed using more lines.. line 70 for example is not only too long but it calculates the number of neighbors two times when it could have been done once with an extra line before..
I learned a lot with this.
I hope you like it
Code: Select all
10 DIM A$(1536)
20 LET A$(99 TO 286)="% % % % % % % % % "
30 PRINT AT 0,0;A$(1 TO 384)
40 FOR F=34 TO 351
50 IF A$(F+64)="% " THEN LET A$(768+F+31 TO 768+F+97)="111"+A$(768+F+34 TO 768+F+62)+"111"+A$(768+F+66 TO 768+F+94)+"111"
60 IF A$(768+F)<>"1" THEN GOTO 80
70 IF (A$(F)="% " AND CODE A$(F-33)+CODE A$(F-32)+CODE A$(F-31)+CODE A$(F-1)+CODE A$(F+1)+CODE A$(F+31)+CODE A$(F+32)+CODE A$(F+33)=256) OR CODE A$(F-33)+CODE A$(F-32)+CODE A$(F-31)+CODE A$(F-1)+CODE A$(F+1)+CODE A$(F+31)+CODE A$(F+32)+CODE A$(F+33)=384 THEN LET A$(384+F)="% "
80 NEXT F
90 LET A$=A$(385 TO 768)+A$(1152 TO 1536)+A$(1152 TO 1536)
100 GOTO 30