Brainf**k is a programming language with only 8 commands:
> Move pointer right
< Move pointer left
+ Increment memory at pointer
- Decrement memory at pointer
. Output character at pointer
, Input character to pointer (from Input)
[ Jump forward past matching ] if memory at pointer is 0
] Jump back to matching [ if memory at pointer is not 0
How to Use This UI
Write Brainf**k code in the Code tab.
Click Run to execute, Stop to halt, Reset to clear memory/output/screen.
Use the Input field for , commands
View memory in the Memory tab.
Game Mode: When enabled, the first 256 memory cells are visualized as a 16x16 pixel screen (see below). The . command updates the screen, instead of printing a character to the output.
When Game Mode is off, . prints to the output.
When Color Screen is enabled, the screen is colored (see below), else the screen is grayscale (0 - 255).
Colors Legend
Each value (0-255) is mapped to a unique color: 16 hues × 16 brightnesses. Hue = value % 16, Brightness = value / 16. Used for Color Screen mode.
>+ // Move to 2nd pixel and set it to 1
[ // Loop until value at pointer is 0
[->+>+<<] // Copy value at pointer to next two cells
>>[-<<+>>]< // Move value back to this cell
+. // Increment next cell and draw the screen
]
Fills the first 256 memory cells with values 0 to 255 (for visualizing the full color palette in Game Mode).
Reverse Input
,[>,] // Load the string into memory one char at a time
<[.<] // Print the string in reverse order
Reads a string from input and prints it in reverse order.
"The Parrot"
<+ // Set up infinite Loop
[>
, // Read character from input
[.>] // If it isn't 0 output it and move to a cell with 0 value
<]
Says the same thing back to you. (Don't run in game mode)
Draw a Diagonal Line
++++++++++++++++ // Set the length of the diagonal line
[ // Repeat until reached required number of pixels (length)
[->+>>>>>>>>>>>>>>>>+<<<<<<<<<<<<<<<<<] // Copy current pixel to the next diagonal pixel and leave a copy
>[-<+>] // Restore the copy to the original pixel
>>>>>>>>>>>>>>>>- // Move to the next diagonal pixel and subtract by one
]
<<<<<<<<<<<<<<<<< // Move back to last pixel
[ // Repeat until we are back at the beginning
[-]- // Set the current pixel to 0 and then to 255
<<<<<<<<<<<<<<<<<
]
Draws a diagonal line on the 16x16 screen in Game Mode.
Draw a Circle
(Not yet solved 😒)
Draws a circle on the 16x16 screen in Game Mode.
Draw a Checkerboard Pattern
++++++++ // Set number of double rows
[ // Loop until double row count is 0
[->>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>+<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<] // Copy double row count to next row
->>->>->>->>->>->>->>->>> // Draw first row
->>->>->>->>->>->>->>-> // Draw second row
- // Subtract from the double row count
]
Fills the screen with a checkerboard pattern in Game Mode.
A dot that moves with WASD
(Not yet solved 😒)
Moves a dot around the screen using the WASD keys.