Makina

makina (always spelled lowercase, even at the beginning of a sentence) is a two-dimensional cell-based esoteric programming language, which uses "automatons" (essentially fancy instruction pointers) which move around the program executing instructions.
== Design ==
makina's defining trait is its use of "automatons", virtual robots that act similar to instruction pointers in other two-dimensional languages. The automatons move around the program, interpreting each character as one command. Critically, automatons can create new automatons, or "children", which can then collect data for their parent.
=== States ===
Automata can be in three states: Moving, Waiting, or Reading. Moving and Waiting are the important ones. (Reading is only used for literals, see below) All automata start in the default state of Moving, in which they will execute the instruction at their current position and then move one step in the direction they are facing once per tick. If the instruction in question takes no parameters, then they will do this until they run into a space character, run into a character that causes them to halt, or leave the bounds of the program. However, if the instruction has one or two parameters, they will enter the Reading state. In this state, the automata will first create one new child for each parameter, facing either left or right relative to the parent automaton. (The first parameter will spawn one facing right, and the second will spawn facing left.) The parent will then wait until both children have halted and execute the instruction at its current position with the children's return values as arguments.
==== The Reading state and literals ====
The Reading state is how makina handles literals, which by necessity span multiple cells. There are currently two literal types: numbers and strings, represented by the n and t instructions respectively. Once an automaton executes one of these two instructions, it gets put into the Reading state. While in this state, it will interpret (with some exceptions) every character it runs over as a character in the literal. This state can only be exited properly by the automaton reading a semicolon (;), which sets its return value to the completed literal. If the automaton halts in a different manner, such as by running off the edge of the world, its return value will not be set. Note that the automaton does not halt upon reading a semicolon, allowing it to execute further instructions that modify the return value if needed.
==== Return values ====
Many instructions change the automaton's return value. The return value will be sent back to the automaton's parent, it it has one, when the automaton halts. Return values are not sent back to the parent until the automaton halts, which means that they can be further processed by any subsequent instructions the automaton follows.
=== Memory ===
makina stores data in an infinite dictionary of cells, each of which can have a key or value of any valid literal type.
== Example ==
 >P
 >t:Hello, World!;
This is a makina hello world program. Each character of the program occupies one cell, and represents one instruction for the automaton. When a makina program is first run, there is only one automaton in the world. All other automata will be descended from this one. It always starts in the top-left corner, facing downwards. The first instruction of the program is a left arrow (>), which rotates the automaton to face left. It then moves left, into the P or "print" instruction. This instruction takes one parameter, so the automaton then spawns a new child automaton, facing right (relative to its parent). This automaton travels downwards, turns right, and then runs over the t or "start text" instruction, putting it into reading mode as described above. It reads the text "Hello, World!", hits the semicolon, and then runs off the edge of the map, halting and returning the string "Hello, World!" to its parent. That string is then printed by the print instruction, and then the root automaton runs off the edge of the program as well, halting and ending the program.
== Instruction list ==
 Instruction list
Instruction 	Parameters 	Returns 	Usage 	Notes
(space character)	None 	Halts the automaton. 	 	
; 	None 	None 	Ends a literal. Does not halt the automaton. 	If the automaton is not reading, acts as a noop.
: 	None 	None 	If the automaton is reading, forces it to interpret the next character as part of the literal, even if it would normally be interpreted as an instruction. Works similarly to a backslash in Python string literals.	If the automaton is not reading, acts as a noop.
^ 	None 	None 	Rotates the automaton in-place to face upwards. 	
> 	None 	None 	Rotates the automaton in-place to face right. 	
v 	None 	None 	Rotates the automaton in-place to face downwards. 	
< 	None 	None 	Rotates the automaton in-place to face right. 	
O 	None 	None 	Acts as a noop. Does not modify the direction of the automaton. 	
H 	None 	None 	Halts any automata approaching from the left or right, otherwise acts as a noop. 	
I 	None 	None 	Halts any automata approaching from the top or bottom, otherwise acts as a noop. 	
J 	None 	None 	Moves the automaton forward one space, effectively "jumping" over the next instruction. 	
U` 	None 	None 	Rotates the automaton 180° and then jumps it forward one space. Nice when you have a single-parameter instruction facing in an inconvenient direction. 	
P 	The thing to print 	None 	Prints its parameter to the output (which may vary between screens, see below). 	
p 	The thing to print 	None 	Works just like `P`, but doesn't print a trailing newline. 	
r 	None 	None 	Works just like `P`, but prints the automaton's return value instead. 	
i 	None 	The string read from the input 	Reads a string from the input (which may vary between screens, see below). 	
E 	None 	The number read from the input 	Works just like `i`, but converts the input to an integer first. 	
T 	The thing to index, and the index to get 	The item at that index 	Equivalent to `thing[index]` in python. Most useful with strings. 	
+ 	The two things to add together 	The sum of the two things 	Adds two things together. 	
* 	The two things to multiply together 	The product of the two things 	Multiplies two things together. 	
- 	The two things to subtract from each other 	The difference of the two things 	Subtracts its first parameter from its second one 	
/ 	The two things to divide by each other 	The quotient of the two things 	Divides its first parameter by its second one 	
% 	The two things to divide by each other 	The remainder of the division 	Divides its first parameter by its second one, and returns the remainder 	
u 	The index of the cell to increment 	None 	Attempts to increment the cell at the passed index by one. 	If the cell does not exist, it will be set to one.
d 	The index of the cell to decrement 	None 	Works just like `u`, but decreases the cell by one instead. 	
m 	The thing to cast 	The casted thing 	Casts its input to an integer 	
s 	The thing to cast 	The casted thing 	Works just like `m`, but casts to a string instead. 	
N 	None 	None 	Works just like `m`, but casts the automaton's return value in-place. 	
S 	None 	None 	Works just like `s`, but casts the automaton's return value in-place. 	
L 	The thing to find the length of 	The length of the thing 	Returns the length of its input. 	
l 	The two things to compare 	If the first thing was less than the second 	Returns if the second input is less than the first one. 	Compared to most instructions, this instruction takes its parameters backwards (thing one is the second input and thing two is the first).
g 	The two things to compare 	If the first thing was greater than the second 	Returns if the second input is greater than the first one. 	Compared to most instructions, this instruction takes its parameters backwards (thing one is the second input and thing two is the first).
e 	The two things to compare 	If the first thing was less than or equal to the second 	Returns if the second input is less than or equal to the first one. 	Compared to most instructions, this instruction takes its parameters backwards (thing one is the second input and thing two is the first).
o 	The two things to compare 	If the first thing was greater than or equal to the second	Returns if the second input is greater than or equal to the first one. 	Compared to most instructions, this instruction takes its parameters backwards (thing one is the second input and thing two is the first).
= 	The two things to compare 	If the inputs are equal 	Returns if the inputs are equivalent. 	
? 	A boolean value 	None 	Turns the current automaton right if the input is true and left otherwise. Does not spawn a new automaton. 	Uniquely, this instruction will always spawn its child facing forwards, instead of right.
w 	The thing to write and the cell to write it in	None 	Writes its first parameter to the cell at the index specified by the second parameter. 	
C 	The index to read from 	The thing read 	Reads and returns the value of the cell at the index specified by the first parameter. 	If the cell does not exist, 0 will be returned.
x 	None 	None 	Prints the contents of memory to output. Intended to be used for debugging purposes. 	
Characters n and t, while not technically instructions, mark the start of number and string literals.
== Running makina programs ==
The pymakina interpreter can be installed from pypi wherever package installers are sold. You can then simply use the `makina` command in a terminal.
Category: Languages Category:2022 Category:Turing complete Category:Cell-based Category:Concurrent_programming Category:Two-dimensional languages Category:Implemented