Advertisement
linesguy

Randomised next nearest neighbour CA (update)

Mar 29th, 2017
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.02 KB | None | 0 0
  1. 0 rem Update mar 30: Re-write of the huge chunk of code at the end. Despite there being more code it's now about 10% faster.
  2.  
  3. 0 rem Every time you run this program, It generates a random ruleset, If you want to manually input a ruleset, Then do it in line 12.
  4.  
  5. 2 width = 150 : rem max 277
  6.  
  7.  
  8.  
  9. 10 hgr : for x = 1 to 40 : print : next : print "Rule:" : for re = 1 to peek(78)+peek(78)+peek(78)+peek(78) : er = rnd(1) : next : for re = 1 to 32 : rule$ = rule$ + str$(int(rnd(1)*2)) : next
  10. 12 rem Rule$ = " "
  11. 13 print rule$ : for X = 2 to width : hcolor = int(rnd(1)*2)*3 : hplot X,0 : next
  12. 16 hcolor = 3
  13. 17 hplot 0,0 to 0,191 : hplot 1,0 to 1,191
  14. 18 hplot width+1,0 to width+1,191 : hplot width+2,0 to width+2,191
  15. 20 for Y = 0 to 140
  16. 30 for X = 2 to width
  17.  
  18. 1000 if hscrn(X-2,Y) = 3 then goto 2000
  19. 1010 goto 2020
  20.  
  21. 2000 if hscrn(X-1,Y) = 3 then goto 3000
  22. 2010 goto 3020
  23. 2020 if hscrn(X-1,Y) = 3 then goto 3040
  24. 2030 goto 3060
  25.  
  26. 3000 if hscrn(X,Y) = 3 then goto 4000
  27. 3010 goto 4020
  28. 3020 if hscrn(x,y) = 3 then goto 4040
  29. 3030 goto 4060
  30. 3040 if hscrn(x,y) = 3 then goto 4080
  31. 3050 goto 4100
  32. 3060 if hscrn(x,y) = 3 then goto 4120
  33. 3070 goto 4140
  34.  
  35. 4000 if hscrn(X+1,Y) = 3 then goto 5000
  36. 4010 goto 5020
  37. 4020 if hscrn(X+1,Y) = 3 then goto 5040
  38. 4030 goto 5060
  39. 4040 if hscrn(x+1,y) = 3 then goto 5080
  40. 4050 goto 5100
  41. 4060 if hscrn(x+1,y) = 3 then goto 5120
  42. 4070 goto 5140
  43. 4080 if hscrn(x+1,y) = 3 then goto 5160
  44. 4090 goto 5180
  45. 4100 if hscrn(x+1,y) = 3 then goto 5200
  46. 4110 goto 5220
  47. 4120 if hscrn(x+1,y) = 3 then goto 5240
  48. 4130 goto 5260
  49. 4140 if hscrn(x+1,y) = 3 then goto 5280
  50. 4150 goto 5300
  51.  
  52. 5000 if hscrn(X+2,Y) = 3 then hcolor = val(mid$(rule$,1,1))*3 : hplot X,Y+1 : goto 6000
  53. 5010 hcolor = val(mid$(rule$,2,1))*3 : hplot X,Y+1 : goto 6000
  54. 5020 if hscrn(X+2,Y) = 3 then hcolor = val(mid$(rule$,3,1))*3 : hplot X,Y+1 : goto 6000
  55. 5030 hcolor = val(mid$(rule$,4,1))*3 : hplot X,Y+1 : goto 6000
  56. 5040 if hscrn(x+2,y) = 3 then hcolor = val(mid$(rule$,5,1))*3 : hplot x,y+1 : goto 6000
  57. 5050 hcolor = val(mid$(rule$,6,1))*3 : hplot X,Y+1 : goto 6000
  58. 5060 if hscrn(x+2,y) = 3 then hcolor = val(mid$(rule$,7,1))*3 : hplot x,y+1 : goto 6000
  59. 5070 hcolor = val(mid$(rule$,8,1))*3 : hplot X,Y+1 : goto 6000
  60. 5080 if hscrn(x+2,y) = 3 then hcolor = val(mid$(rule$,9,1))*3 : hplot x,y+1 : goto 6000
  61. 5090 hcolor = val(mid$(rule$,10,1))*3 : hplot X,Y+1 : goto 6000
  62. 5100 if hscrn(x+2,y) = 3 then hcolor = val(mid$(rule$,11,1))*3 : hplot x,y+1 : goto 6000
  63. 5110 hcolor = val(mid$(rule$,12,1))*3 : hplot X,Y+1 : goto 6000
  64. 5120 if hscrn(x+2,y) = 3 then hcolor = val(mid$(rule$,13,1))*3 : hplot x,y+1 : goto 6000
  65. 5130 hcolor = val(mid$(rule$,14,1))*3 : hplot X,Y+1 : goto 6000
  66. 5140 if hscrn(x+2,y) = 3 then hcolor = val(mid$(rule$,15,1))*3 : hplot x,y+1 : goto 6000
  67. 5150 hcolor = val(mid$(rule$,16,1))*3 : hplot X,Y+1 : goto 6000
  68. 5160 if hscrn(x+2,y) = 3 then hcolor = val(mid$(rule$,17,1))*3 : hplot x,y+1 : goto 6000
  69. 5170 hcolor = val(mid$(rule$,18,1))*3 : hplot X,Y+1 : goto 6000
  70. 5180 if hscrn(x+2,y) = 3 then hcolor = val(mid$(rule$,19,1))*3 : hplot x,y+1 : goto 6000
  71. 5190 hcolor = val(mid$(rule$,20,1))*3 : hplot X,Y+1 : goto 6000
  72. 5200 if hscrn(x+2,y) = 3 then hcolor = val(mid$(rule$,21,1))*3 : hplot x,y+1 : goto 6000
  73. 5210 hcolor = val(mid$(rule$,22,1))*3 : hplot X,Y+1 : goto 6000
  74. 5220 if hscrn(x+2,y) = 3 then hcolor = val(mid$(rule$,23,1))*3 : hplot x,y+1 : goto 6000
  75. 5230 hcolor = val(mid$(rule$,24,1))*3 : hplot X,Y+1 : goto 6000
  76. 5240 if hscrn(x+2,y) = 3 then hcolor = val(mid$(rule$,25,1))*3 : hplot x,y+1 : goto 6000
  77. 5250 hcolor = val(mid$(rule$,26,1))*3 : hplot X,Y+1 : goto 6000
  78. 5260 if hscrn(x+2,y) = 3 then hcolor = val(mid$(rule$,27,1))*3 : hplot x,y+1 : goto 6000
  79. 5270 hcolor = val(mid$(rule$,28,1))*3 : hplot X,Y+1 : goto 6000
  80. 5280 if hscrn(x+2,y) = 3 then hcolor = val(mid$(rule$,29,1))*3 : hplot x,y+1 : goto 6000
  81. 5290 hcolor = val(mid$(rule$,30,1))*3 : hplot X,Y+1 : goto 6000
  82. 5300 if hscrn(x+2,y) = 3 then hcolor = val(mid$(rule$,30,1))*3 : hplot x,y+1 : goto 6000
  83. 5310 hcolor = val(mid$(rule$,32,1))*3 : hplot X,Y+1 : goto 6000
  84.  
  85. 6000 next : next
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement