NTCM

NTCM is an esoteric programming language developped by user:Slereah. It is based on a Turing machine with multiple tapes and I/O (the name stands for n-tape choice machine).

Language overview
A NTCM program consists of a list of states, each with accepting symbols for a list of instructions, an initial state and initial input. The instructions are :


 * LE : Move the head to the left
 * RI : Move the head to the right
 * Px : Print the symbol x on the current cell (LF for new line, TB for tab)
 * CH : Awaits input from the keyboard and print it on the current cell
 * DI : Display the symbol of the current cell on the screen
 * ER : Print the empty symbol on the current cell
 * UP : Move to the tape above
 * DW : Move to the tape below
 * DN : Do nothing
 * HA : Halt the program

The %(N/0-a1>Instructions/a1+1-a2>Instructions/. . ./an+1-N>Instructions) instruction (replace ai with appropriate numbers) generates a number between 0 and N, and execute the instructions of the interval containing the generated numbers.

The syntax of a program is the following (all whitespaces are ignored except space itself) :

[

q0[S0:Instructions:qa;S1:Instructions:qb;...;cr:Instructions:qi]|

q1[Sa:Instructions:qx;Sb:Instructions:qy;...;cr:Instructions:qz]|

q2[...]|...|qn[...]

]

[0=#;ims=q0;nd;nh;etFecF;t1]

Where the q are replaced by the appropriate state names (avoid the characters used for syntax in the name) and the S by the appropriate character (or LF and TB for new line and tab). cr stands for all the remaining characters. The first line should be read as "When in state q0, if the current cell has the symbol S0, perform the instructions and go in new state qa" and so on.

The last line indicates the empty symbol (0=x for the empty symbol x), the initial state (ims=x), whether the tape should be displayed or not (nd if not, dx else, where x will be the number of cell displayed to the left and right of the current cell), whether the head should be displayed or not (nh or vh, the head being the current state and current cell), whether the whole tape should be displayed at the end of the program, with or without the surrounding empty symbols (etTecT will display everything, etTecF the relevent section of the tape, etFecF nothing), and the number n of tapes tn. It is also possible to add ";[some file path]" after tn to indicate what should be put on the first tape.

Comments can be added in the form of never used states, such as : comment[ :Comments here: ]|

Minimal syntax
The minimal syntax only uses four characters : *, +,. A program is in the following form :

*++...++*++...++*++...++< (or >) *++...++**++...++*++...++*++...++< (or >) *++...++**...

It indicates the number of the first state (how many +'s next to the first *), the number of the accepting symbol (second), the symbol to print (third), the direction to move the head and the new state (fourth). If there's a fifth *, it indicates a new state, or an old one with another accepting symbol.

To print nothing, a state should be of the form qx, Sa : PSa, (left or right), qy. To erase the current cell, use PS0 (No +'s). To avoid moving, use qx, Sa : PSb, right, qy ; qy, Sb : PSb, left, qz. The current implementation use S0 for #, S1-S10 for 0-9, S11-S36 for a-z, S37-S62 for A-Z and other symbols above 63.

The minimal syntax doesn't allow input, output and the program won't stop on its own. The tape and head of the machine are simply displayed displayed on the screen (31 cells at a time).

Going Postal
A stripped down version of NTCM based on the Post-Turing machine. The syntax is just a collection of state of the following types, separated by colons :

qa:@:qb - In state qa, change 0 in 1 or 1 in 0, then go in state qb

qa:>:qb - in state qa, go to the cell on the right, then go in state qb

qa:<:qb - in state qa, go to the cell on the left, then go in state qb

qa:!:qb - in state qa, halt the machine (qb isn't actually important. Use qa for instance)

qa:qb:qc - in state qa, go in state qb if the current cell is 0, or in state qc if the current cell is 1.

For input and output, the tape is divided into bytes. 0 to 7, 7 to 15, -9 to -1, etc. So that we have :

qa:.:qb - in state qa, print the byte as ASCII on the screen (the head of the machine won't move).

qa:,:qb - in state qa, change the whole byte according to the keyboard's input.

Examples
Hello, world! :

[a[#:PHDIPeDIPlDIDIPoDIP,DIP DIPwDIPoDIPrDIPlDIPdDIP!DIHA:a]][0=#;ims=a;nd;nh;etFecF;t1]

With minimal syntax :

***++++++++++++++++++++++++++++++++++++++++++++>*+**+**+++++++++++++++>*++* *++**++++++++++++++++++++++>*+++**+++**++++++++++++++++++++++>*++++* *++++**+++++++++++++++++++++++++>*+++++**+++++* *+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++>*++++++* *++++++**+++++++++++++++++++++++++++++++++>*+++++++**+++++++**+++++++++++++++++++++++++>*++++++++* *++++++++**++++++++++++++++++++++++++++>*+++++++++**+++++++++**++++++++++++++++++++++>*++++++++++* *++++++++++**++++++++++++++>*+++++++++++* *+++++++++++**+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++>*++++++++++++* *++++++++++++**>*+++++++++++++**+++++++++++++**<*++++++++++++

Going Postal

Cat program :

[a[cr:CHDI:a]][0=#;ims=a;nd;nh;etFecF;t1]

4-states-2-symbols Busy Beaver :

[ a[0:P1RI:b;1:P1LE:b]| b[0:P1LE:a;1:P0LE:c]| c[0:P1RIHA:c;1:P1LE:d]| d[0:P1RI:d;1:P0RI:a] ] [0=0;ims=a;d13;vh;etTecT;t1]

Computational class
The language describing a Turing machine, it is Turing complete if we assume the tape infinite.

External ressources

 * Python interpreter. Uses winsound. Use this version for Linux.
 * Commented 99 program
 * A brainfuck interpreter (will not work on the Linux version) and a Bitchanger interpreter
 * The outline for a 1-tape version of the brainfuck interpreter
 * Going Postal