Advertisement
Guest User

turing.txt

a guest
Sep 16th, 2014
328
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.57 KB | None | 0 0
  1. /*
  2. black = 16
  3. white = 1
  4. magenta = 3
  5. lightBlue = 4
  6. cyan = 10
  7. */
  8.  
  9. tape[32] // an array of colors. each element is either black (16) or white (1)
  10. state // the color of the head. starts as magenta (3) and can be either magenta (3), lightBlue (4), or cyan (10)
  11. xPos // position the head is at along the tape array. if it moves out of bounds, it loops to the other side
  12. yPos // height that the next array will be displayed. decrements each round from 31. when negative, resets back to 31.
  13.  
  14. // make the entire tape black
  15. function initializeTape:
  16. index
  17. arg
  18. {
  19. index = 0;
  20. while (index < 32) {
  21. arg = index + 11;
  22. print(arg);
  23. save(16, tape, index);
  24. index++;
  25. }
  26. }
  27.  
  28. function display:
  29. index
  30. atHead
  31. arg
  32. {
  33. gpu.push();
  34. print(1);
  35. index = 0;
  36. while (index < 32) {
  37. arg = index + 43;
  38. print(arg);
  39. load(atHead, tape, index);
  40. gpu.plot(index, yPos, atHead);
  41. index++;
  42. }
  43. gpu.plot(xPos, yPos, state);
  44. }
  45.  
  46. function main:
  47. atHead
  48. {
  49. print(0);
  50. initializeTape();
  51.  
  52. state = 3; // state is initially magenta
  53. yPos = 32;
  54. xPos = 15;
  55.  
  56. while (true) {
  57. print(0);
  58. load(atHead, tape, xPos);
  59. if (state = 3) { // if state is magenta
  60. print(1);
  61. if (atHead = 1) { // if tape at head is white
  62. save(16, tape, xPos) // make tape at head black
  63. state = 4; // make state lightBlue
  64. xPos++; // move right
  65. continue;
  66. }
  67. print(2);
  68. // else if tape at head is black
  69. save(1, tape, xPos) // make tape at head white
  70. state = 10; // make state cyan
  71. xPos--; // move left
  72. continue;
  73. }
  74. print(3);
  75. if (state = 4) { // if state is lightBlue
  76. print(4);
  77. if (atHead = 1) { // if tape at head is white
  78. // tape at head remains white
  79. state = 10; // make state cyan
  80. xPos++; // move right
  81. continue;
  82. }
  83. print(5);
  84. // else if tape at head is black
  85. save(1, tape, xPos); // make tape at head white
  86. state = 3; // make state magenta
  87. xPos++; // move right
  88. continue;
  89. }
  90. print(6);
  91. if (state = 10) { // if state is cyan
  92. print(7);
  93. if (atHead = 1) { // if tape at head is white
  94. save(16, tape, xPos); // make tape at head black
  95. state = 3; // make state magenta
  96. xPos--; // move left
  97. continue;
  98. }
  99. print(8);
  100. // else if tape at head is black
  101. save(1, tape, xPos); // make tape at head white
  102. state = 4; // make state lightBlue
  103. xPos++; // move right
  104. continue;
  105. }
  106. print(9);
  107. if (xPos = 32) {
  108. xPos = 0;
  109. }
  110. if (xPos < 0) {
  111. xPos = 31;
  112. }
  113. print(10);
  114. yPos--;
  115. if (yPos < 0) {
  116. gpu.clear();
  117. yPos = 31;
  118. }
  119.  
  120. display();
  121. }
  122.  
  123. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement