Amtu

Amtu (derived from the name Alan Mathison Turing) is a cell-based Turing-complete esoteric programming language created by User:TheCanon2. Amtu is designed to be used as notation for Turing machines. Amtu's alphabet consists of three symbols, blank, 0, and 1.
==Commands==
Lines in Amtu define states of a Turing machine. Lines in Amtu require seven parameters. These parameters can be of any length.
Parameter 	Execute if the cell of the pointer is
name 	N/A
action 	blank
state change	blank
action 	0
state change	0
action 	1
state change	1
Amtu assumes the existence of an infinitely long tape with a single pointer. The action parameters have six commands.
Command	Action
< 	Move the pointer to the left
> 	Move the pointer to the right
0 	Write 0 at the cell of the pointer
1 	Write 1 at the cell of the pointer
h 	Halt the program
= 	Pass
Since all code written in Amtu is in this format, Amtu can be considered a single-instruction language.
When the Turing machine defined by an Amtu script is executed, Amtu accepts an input at the beginning of a program. The initial tape is all blank unless given an input. The initial state becomes the first state defined in the script. User input must be in the format of (data).(data), the cell before the period becomes the cell of the pointer.
Scripts in Amtu are encoded in ASCII. This detail is only significant when making quines.
==Examples==
It is important to note that the following examples are not programs, they define programs.
===XKCD Random Number===
F 0>0>1>1>0>1>0>0h F 0>0>1>1>0>1>0>0h F 0>0>1>1>0>1>0>0h F
Defines a Turing machine that unconditionally writes the character 4 to the tape as binary, since Amtu has no output.
===The Turing machine described here===
N = S = S 0> N
S 1< S 1< S = N
which can be simplified to:
L 1< L 1< L 0> L
===The table shown here===
A 1> B 1> B 1< C
B 1> C 1> C 1> B
C 1> D 1> D 0< E
D 1< A 1< A 1< D
E 1>h E 1>h E 0< A
Writing an Amtu script from a table is trivial.
===Rule 110===
S <<<<<<<<<<<<<<<<<<< R <<<<<<<<<<<<<<<<<<< R <<<<<<<<<<<<<<<<<<< R
R > Z > Z > O
Z > ZZ > ZZ > ZO
O > OZ > OZ > OO
ZZ = W = W = B
ZO = B = B = B
OZ = W = W = B
OO = B = B = W
B >>>>>>>>>>>>>>>>>1>> S >>>>>>>>>>>>>>>>>1> S >>>>>>>>>>>>>>>>>1> S
W >>>>>>>>>>>>>>>>>0>> S >>>>>>>>>>>>>>>>>0> S >>>>>>>>>>>>>>>>>0> S
Defines a 16-cell implementation that leaves behind every generation, given input 0000000000000000__. This script is buggy.
===Canon===
A < R < R < R
R > Z > Z > O
Z > ZZ > ZZ > ZO
O > OZ > OZ > OO
ZZ <1< A <1< A <1>> A
ZO <0<< A <0<< A <0> A
OZ <1>> A <1<< A <1<< A
OO <0> A <0> A <0< A
Defines Canon as a Turing machine.
===Implementations===
The following Python script is an interpreter.
tape = [" "]
for i in range(0, 256): # Change this for expansion
 tape.append(" ")
program = [[0]]
while True:
 line = input('>Amtu ')
 if not line == "eof":
 program.append(list(line.split(" ")))
 else:
 program.pop(0)
 break
init = input('>i ') # Grabs input from user
for i in range(0, len(init)):
 if init[i] == ".":
 init = init.replace('.', )
 pointer = 128-i # Change this for expansion
 break
for i in range(0, len(init)):
 pointer += 1
 tape[pointer] = init[i]
# done
pointer = 128 # Change this for expansion
line = 0
part = 0
while True:
 part = 0
 if tape[pointer] == " ":
 part = 1
 elif tape[pointer] == "0":
 part = 3
 elif tape[pointer] == "1":
 part = 5
 for inst in range(0, len(program[line][part])):
 cmd = program[line][part][inst]
 if cmd == "<":
 pointer -= 1
 elif cmd == ">":
 pointer += 1
 elif cmd == "0":
 tape[pointer] = "0"
 elif cmd == "1":
 tape[pointer] = "1"
 elif cmd == "h":
 break
 elif cmd == "=":
 pass
 elif cmd == "#": # Debug character
 print(pointer)
 print(tape)
 if cmd == "h":
 break
 else:
 part += 1
 goto = program[line][part]
 line = 0
 while program[line][0] != goto:
 line += 1
Executes the Turing machine defined by a script. The interpreter uses the symbols eof to mark the end of a script and # to display the tape. 256-cell implementation, but it can be expanded.
Category:Languages
Category:Cell-based
Category:Turing complete
Category:Turing tarpits
Category:Implemented
Category:Low-level
Category:OISC
Category:2024