Braingrate

From Esolang
Jump to navigation Jump to search
Braingrate
Paradigm(s) imperative
Designed by User:Aadenboy
Appeared in 2022
Memory system Cell-based
Dimensions one-dimensional
Computational class Turing complete
Major implementations Lua Program made to interpret Braingrate
Influenced by brainfuck
Influenced None
File extension(s) .txt files named "braingratescript"

Braingrate is a parody of brainfuck created by User:Aadenboy which adds seven new commands to supposedly make programs easier to work with. It is entirely written in Lua, and the interpreter is exactly 3,000 bytes big (including comments). The interpreter only accepts any .txt files named "braingratescript".

Language Overview

Braingrate uses commands like brainfuck's, but there is also a set of extra commands with their own functions too. All cells may only be 0-255 in value, and there is only 256 cells to be worked with. The pointer always starts off at the first cell (cell 0).

Command Description
> Move the pointer to the right
< Move the pointer to the left
+ Increment the chosen cell's value up by one
- Decrement the chosen cell's value down by one
. Output the ASCII character corresponding to the chosen cell's value
: Output the chosen cell's value
, Gets input from the user as a number and stores it into the chosen cell
; Gets input from the user as any valid ASCII character and stores the ASCII code into the chosen cell
[ Create a loop starting at this command's position in the script
] Go back to the previous [ command only if the chosen cell's value is 0
= Copy the chosen cell's value to the cell to the left of it
? Set the chosen cell's value to a random value from 0-255
* Ignore the rest of the commands if the current cell is equal to the previous one until another * command is found
^ Skip the next command
# End the program

Any other characters will be treated as comments.

Example Programs

Truth Machine

This program below is an example of a Truth Machine.

,[:]

While the program is a valid truth machine, it doesn't seem like one when dealing with other values such as 176, or 255. The program below accounts for that, and will print a 0 if it is not 1, otherwise it will indefinitely print 1s.

,=<-*>[-]<^*>[:]

One Time Cat

The cat machine program has exactly two variations. This first program will output whatever number was inputted.

,:

This second program will output whatever ASCII character was inputted.

;.