AutomataFuck

From Esolang
Jump to navigation Jump to search
This is still a work in progress. It may be changed in the future.
AutomataFuck
Paradigm(s) String-rewriting
Designed by GoodCoderBBoy
Appeared in 2021
Memory system Cell-based
Dimensions one-dimensional
Computational class Linear bounded automata
Major implementations Original
File extension(s) .atmf
Note that I (GoodCoderBBoy) hate strongly disapprove of swearing.

AutomataFuck is an esoteric language that requires you to think in circles created by User:GoodCoderBBoy.

Language overview

AutomataFuck operates on the code fed into it, where each character of which's base-10 value is stored in a cell. There is a pointer, initially pointing to cell 0. Once a cell's value exceeds 1114111, it rolls over to 0 and likewise when set to -1, will roll back to 1114111. The valid instructions are:

Instruction Description
# Start/end comment
~ Start/end parsing a .atmf file name to be run
, Clear the output
< Move the pointer a cell to the left
> Move the pointer a cell to the right
{ Move the pointer 10 cells to the left
} Move the pointer 10 cells to the right
$ Move the pointer to after the leftmost newline
@ Move the pointer to the rightmost newline
? Toggle whether the pointer will move to cell 0 at the start of the next iteration (defaults to true)
% Jump execution to the location of the pointer
^ Skip the next instruction if the pointer does not point to this cell
[ Declare the start of the loop
] Declare the end of the loop and move to the start if the pointer does NOT point to a cell of value 0 AND The loop hasn't executed n times where n is the value of the cell before the start of the loop
: Set the value of the cell at the pointer to 0
- Decrement the value of cell at the pointer
+ Increment the value of the cell at the pointer
) Decrement the value of the cell at the pointer by 10
( Increment the value of the cell at the pointer by 10
* Square the value of the cell at the pointer
. Halt the program and exit
; Print the ASCII value of the cell at the pointer
_ Print the numerical value of the cell at the pointer
! Jump execution to the next iteration if the cell at the pointer does NOT have an ASCII value of ., !, $, or @ AND the pointer is not at the end of the tape
| Replace the cell at the pointer with the base 10 value of the ASCII character the user inputted
` Replace the cell at the pointer with the number the user inputted

Any thing else will be considered no-op.


Code is executed from left to right, line by line unless some form of flow control instruction is used. All characters other than those above will not be executed, but are still stored in the memory tape. After an iteration has finished executing, a new iteration will be created where:

  • The new code will the replace the old code
  • The pointer will be reset to cell 0 unless ? is used to specify this not happening
  • The new code will be executed

A new iteration is not created, nor will execution continue when the program halts.


AutomataFuck will halt and exit when:

  • The pointer's absolute value is greater than or equal to the length of the program (because the first cell has and index of 0)
  • The program is halted using .
  • If a ! is reached and the pointer points to a ., !, $, or @.


AutomataFuck DOES NOT SUPPORT NESTED LOOPS. The program will simply overwrite the old loop.

Examples

Hello, World!

This program clears the terminal, outputs "Hello, World!", then halts:

^,;?>�����#�Hello, World!#� 

Note: The program has a space at the end and the control character � has a base-10 value of 8.

Quine

This is one of the easiest programs in AutomataFuck, needing only 3 characters:

?;>

That's it! Anything can be appended on as long as it doesn't affect the execution (if it does comment it out or something):

?;>Foo Bar #Hello, World!#

Multi-use echo statement

This is one of the hardest programs to create: A modular echo command that can be used more than once without breaking:

$�[;?>������Text Here]� 
$�[;?>�����Even more text]� 

Once again using the control character � and each line being followed by a space. But wait! On each line, after the $ character, a different character is used. This depends on what is being echoed. It must have a base 10 value of n where n is the number of characters on it's line (including that space and itself) PLUS one.

Adder

`}<<<<`[$+]$_.

Limitations: Can only compute a problem where the addends and the sum are less than 1114111 (until more Unicode characters are added in).

Truth-machine

`}<<< :�[$_].

Replace }<<< :� with null (U+0000 / &#0;) and omit $ from [$_] if possible. (file)

More examples

More examples can be found on GitHub within the Author's Repo.

Implementations

Python3