Rook

From Esolang
Jump to: navigation, search

Rook is an esoteric programming language made by Areallycoolusername. It's queue-based and made to be the smallest Turing tarpit ever.

Instructions

Rook only has two instruction and two symbols. The instructions are "T" and "F". The symbols are the same.

Instructions & Symbols Function
T Pushes True to last cell.
F Pushes False to last cell, and when tape is full, acts as the EJECT command would.

Original Idea

The original idea was that the tape had as many cells as there are of the non-control ASCII characters (starting from the 32nd character, and ending on the 126th). Each cell on the tape would represent an ASCII character. For example, the 69th cell represents lowercase "e". When one of the instructions such as a T is pushed on, it goes to the cell that represents the the 126th character, "~" . The T acts as a boolean, and as output, a "-" is printed. If a F was pushed on, then the "-" character wouldn't be printed. The F acts as the EJECT command when the tape is completely filled with F's and T's. It starts with the last character in the tape, and it exchanges T's and F's. F's acted as a HALT command when they're typed twice in a row like "FF". When the double F is detected, the program will stop prompting, print the ASCII characters whose cells held a T, and end the program. However, due to User: A's suggestions, this mechanism has been replaced.

Specifics

However, thanks to User:A in the discussion page, the language wouldn't be Turing-complete, and therefore, not a Turing tarpit. So now, the tape is unbounded, and the first of the first 126 cells in the tape start as the space character instead of the "~" character. The instructions, T and F still function the same as in the original idea, however, the first command will not go to the last cell (if it did, the program wouldn't work, as the tape is infinite). Also, the F command will not act as the EJECT would when the tape is filled, as the tape is infinite. Once the program is finished, you have to put the entire program as input for the interpreter to execute, instead of having to type a Double F.

Hello World Program

Hello world in this program is simple, but very tedious to write. Since the characters in "Hello, world!" aren't in sequential order in the ASCII table and letters can't betwice by typing T two times in a row (For example, "w" in the table comes after "o", so the words wouldn't be complete, it would just be scrambled, and you can't print "l" twice with two T's), you'd have to utilize the many sets of 95 cells that the interpreter prompts you for, while setting the cell representing the ASCII character you want to print as T, while filling the other 94 cells with F's. For example this is just to print H:

F
F
F
F
F
F
F
F
F
F
F
F
F
F
F
F
F
F
F
F
F
F
F
F
F
F
F
F
F
F
F
F
F
F
F
F
F
F
F
F
T
F
F
F
F
F
F
F
F
F
F
F
F
F
F
F
F
F
F
F
F
F
F
F
F
F
F
F
F
F
F
F
F
F
F
F
F
F
F
F
F
F
F
F
F
F
F
F
F
F
F
F
F
F
FF

Typing the code necessary to print hello world would drive anyone insane. So I made a program in C++ that would print the code necessary to print these characters. Replace 41 with whatever place the character you want to print is in (not the decimal place you see on the table). There are 95 valid characters on the table, with H being the 41st one, hence the 41 being the value of x in the program.

#include <iostream>
using namespace std;
int main() { 
    int a = 1; 
    int x = 41; 
    while(a < x) {      
        a++; 
        cout << "F\n"; 
        if(a == x) { 
            a++; 
            cout << "T\n"; 
            while(a < 96) { 
                a++;
                cout << "F\n"; 
            }
        }
    }
    return 0;
}

Here is a much cleaner implementation in C:

main(i){for(i=1;i<=96;++i)printf(i=='H'-31?"T\n":"F\n");}

Implementations

There are no implementations, but they'll be added soon.