D10d3

Conways Game of Life for TRS-80 Model 100

Jul 9th, 2017
220
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. 10 'CONWAY'S GAME OF LIFE BY D10D3 2017
  2. 20 SCREEN 0,0:CLS
  3. 30 PRINT@88,"CONWAY'S GAME OF LIFE";
  4. 40 PRINT@281,"(UP TO 5 DIGITS)";
  5. 50 PRINT@240," ";
  6. 60 INPUT"ENTER RANDOM SEED";SEED%
  7. 70 DIM GRID$(320)
  8. 80 DIM RGRID$(401) 'REFERENCE GRID
  9. 90 GRID$(319)=" ":GRID$(320)=" "
  10. 100 GEN=INT(RND(SEED%*-2))
  11. 110 FOR I=0TO318
  12. 120 PRINT@I,"*";
  13. 130 GEN=INT(RND(1)*2)
  14. 140 IF GEN=1 THEN GRID$(I)="O"
  15. 150 IF GEN=0 THEN GRID$(I)=" "
  16. 160 PRINT@I,GRID$(I);
  17. 170 NEXT I
  18. 180 '***START LIFE LOOP***
  19. 190 'COPY CURRENT GRID TO REFERENCE
  20. 200 S=361
  21. 210 FOR I=0TO39
  22. 220 RGRID$(S)=GRID$(I)
  23. 230 S=S+1
  24. 240 NEXT I
  25. 250 S=1
  26. 260 FOR I=280TO319
  27. 270 RGRID$(S)=GRID$(I)
  28. 280 S=S+1:NEXT I
  29. 290 S=41
  30. 300 FOR I=0TO319
  31. 310 RGRID$(S)=GRID$(I)
  32. 320 S=S+1:NEXT I
  33. 330 RGRID$(0)=GRID$(319)
  34. 340 '***START LIFE RULES***
  35. 350 S=41
  36. 360 FOR I=0 TO 318
  37. 370 PRINT@I,"*";
  38. 380 N=0 'NEIGHBORS
  39. 390 IF RGRID$(S-1)="O"THEN N=N+1
  40. 400 IF RGRID$(S+1)="O"THEN N=N+1
  41. 410 IF RGRID$(S-40)="O" THEN N=N+1
  42. 420 IF RGRID$(S-41)="O"THEN N=N+1
  43. 430 IF RGRID$(S-39)="O"THEN N=N+1
  44. 440 IF RGRID$(S+40)="O"THEN N=N+1
  45. 450 IF RGRID$(S+39)="O"THEN N=N+1
  46. 460 IF RGRID$(S+41)="O"THEN N=N+1
  47. 470 IF N<2 THEN GRID$(I)=" "
  48. 480 IF N>3 THEN GRID$(I)=" "
  49. 490 IF GRID$(I)=" "AND N=3 THEN GRID$(I)="O"
  50. 500 S=S+1
  51. 510 PRINT@I,GRID$(I);
  52. 520 NEXT I
  53. 530 GOTO 180
RAW Paste Data