Advertisement
linesguy

Langton's ant

Mar 18th, 2017
144
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.29 KB | None | 0 0
  1. 0 rem If width is LESS THAN 39 and height is LESS THAN 47,
  2. 0 rem then it automatically switches to low resolution mode (GR).
  3.  
  4. 10 width = 190 : rem max 278
  5. 20 height = 190 : rem max 190
  6.  
  7.  
  8.  
  9. 50 X = int(width/2) : Y = int(height/2) : D = 1
  10. 60 if width < 39 and height < 47 then goto 200
  11.  
  12. 100 hgr2 : hcolor = 1 : hplot width+1,0 to width+1,height+1 to 0,height+1
  13. 110 gosub 3000 : if hscrn(x,y) = 0 then hcolor = 3 : hplot X,Y : gosub 2000
  14. 120 gosub 3000 : if hscrn(x,y) = 3 then hcolor = 0 : hplot X,Y : gosub 1000
  15. 130 goto 110
  16.  
  17. 200 gr : POKE 49234,0 : color = 12 : vlin 0,height+1 at width+1 : hlin width+1,0 at height+1
  18. 210 gosub 3000 : if scrn(x,y) = 0 then color = 15 : plot x,y : gosub 2000
  19. 220 gosub 3000 : if scrn(x,y) = 15 then color = 0 : plot x,y : gosub 1000
  20. 230 goto 210
  21.  
  22.  
  23. 1000 if D = 0 then D = 1 : X = X + 1 : return
  24. 1010 if D = 1 then D = 2 : Y = Y + 1 : return
  25. 1020 if D = 2 then D = 3 : X = X - 1 : return
  26. 1030 if D = 3 then D = 0 : Y = Y - 1 : return
  27.  
  28. 2000 if D = 0 then D = 3 : X = X - 1 : return
  29. 2010 if D = 1 then D = 0 : Y = Y - 1 : return
  30. 2020 if D = 2 then D = 1 : X = X + 1 : return
  31. 2030 if D = 3 then D = 2 : Y = Y + 1 : return
  32.  
  33. 3000 if X > width then X = 0
  34. 3010 if X < 0 then X = width
  35. 3020 if Y > height then Y = 0
  36. 3030 if Y < 0 then Y = height
  37. 3040 return
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement