'=========================================================================== ' Subject: CONWAY'S GAME OF LIFE Date: 08-02-98 (10:05) ' Author: John Wantland Code: QB, QBasic, PDS ' Origin: johnw@ectisp.net Packet: ALGOR.ABC '=========================================================================== REM conway's game of life CLS WIDTH 80 DEFINT A-Z RANDOMIZE TIMER DIM b(25, 82) 'board DIM c(25, 82) 'board FOR x = 0 TO 82 FOR y = 0 TO 25 b(y, x) = 32 c(y, x) = 32 NEXT y NEXT x FOR x = 1 TO 80 FOR y = 1 TO 23 IF INT(RND * 5 + 1) = 3 THEN b(y, x) = 2: c(y, x) = 2 ELSE b(y, x) = 32: c(y, x) = 32 LOCATE y, x: PRINT CHR$(b(y, x)) NEXT y NEXT x DO FOR x = 1 TO 80 FOR y = 1 TO 23 n = 0 IF c(y - 1, x) = 2 THEN n = n + 1 IF c(y - 1, x - 1) = 2 THEN n = n + 1 IF c(y, x - 1) = 2 THEN n = n + 1 IF c(y + 1, x - 1) = 2 THEN n = n + 1 IF c(y + 1, x) = 2 THEN n = n + 1 IF c(y + 1, x + 1) = 2 THEN n = n + 1 IF c(y, x + 1) = 2 THEN n = n + 1 IF c(y - 1, x + 1) = 2 THEN n = n + 1 IF n < 2 OR n > 3 THEN b(y, x) = 32 IF n = 3 THEN b(y, x) = 2 IF INKEY$ <> "" THEN CLS : END NEXT y NEXT x FOR x = 1 TO 80 FOR y = 1 TO 23 LOCATE y, x: PRINT CHR$(b(y, x)) c(y, x) = b(y, x) IF INKEY$ <> "" THEN CLS : END NEXT y NEXT x IF INKEY$ <> "" THEN CLS : END LOOP