Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- black = 16
- white = 1
- magenta = 3
- lightBlue = 4
- cyan = 10
- */
- tape[32] // an array of colors. each element is either black (16) or white (1)
- state // the color of the head. starts as magenta (3) and can be either magenta (3), lightBlue (4), or cyan (10)
- xPos // position the head is at along the tape array. if it moves out of bounds, it loops to the other side
- yPos // height that the next array will be displayed. decrements each round from 31. when negative, resets back to 31.
- // make the entire tape black
- function initializeTape:
- index
- arg
- {
- index = 0;
- while (index < 32) {
- arg = index + 11;
- print(arg);
- save(16, tape, index);
- index++;
- }
- }
- function display:
- index
- atHead
- arg
- {
- gpu.push();
- print(1);
- index = 0;
- while (index < 32) {
- arg = index + 43;
- print(arg);
- load(atHead, tape, index);
- gpu.plot(index, yPos, atHead);
- index++;
- }
- gpu.plot(xPos, yPos, state);
- }
- function main:
- atHead
- {
- print(0);
- initializeTape();
- state = 3; // state is initially magenta
- yPos = 32;
- xPos = 15;
- while (true) {
- print(0);
- load(atHead, tape, xPos);
- if (state = 3) { // if state is magenta
- print(1);
- if (atHead = 1) { // if tape at head is white
- save(16, tape, xPos) // make tape at head black
- state = 4; // make state lightBlue
- xPos++; // move right
- continue;
- }
- print(2);
- // else if tape at head is black
- save(1, tape, xPos) // make tape at head white
- state = 10; // make state cyan
- xPos--; // move left
- continue;
- }
- print(3);
- if (state = 4) { // if state is lightBlue
- print(4);
- if (atHead = 1) { // if tape at head is white
- // tape at head remains white
- state = 10; // make state cyan
- xPos++; // move right
- continue;
- }
- print(5);
- // else if tape at head is black
- save(1, tape, xPos); // make tape at head white
- state = 3; // make state magenta
- xPos++; // move right
- continue;
- }
- print(6);
- if (state = 10) { // if state is cyan
- print(7);
- if (atHead = 1) { // if tape at head is white
- save(16, tape, xPos); // make tape at head black
- state = 3; // make state magenta
- xPos--; // move left
- continue;
- }
- print(8);
- // else if tape at head is black
- save(1, tape, xPos); // make tape at head white
- state = 4; // make state lightBlue
- xPos++; // move right
- continue;
- }
- print(9);
- if (xPos = 32) {
- xPos = 0;
- }
- if (xPos < 0) {
- xPos = 31;
- }
- print(10);
- yPos--;
- if (yPos < 0) {
- gpu.clear();
- yPos = 31;
- }
- display();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement