Floater

Floater is a 2-dimensional esoteric programming language designed by Zom-B in 2014. It's loosely inspired by Piet.

Overview
Floater is a language in which the program is an image and pixels define the instructions. The instruction pointer can move in four directions. The memory layout is random-access and stack-based at the same time. Most instructions operate on the top of the stack, some instructions can access the stack using indirect addressing (random-access). The stack pointer defines how large the 'memory' is; addresses below 1 and above the stack pointer don't exist. The language is weak-typed and all memory location contains real numbers &#x211D;. The size of the stack is unbounded.

The program is self-modifying, and this is in fact the only way to make choices and branches. All 'amounts' are 1-base, meaning the value 1 is the lowest index in all data structures (memory, image, and instruction group). This does not apply to colors.

The author was inspired by PIET, and wanted to make something that didn't require remembering all the cycles, and to make both programming in it and running it easier. Strictly speaking, the former requirement (remembering lots of stuff) hasn't been solved. The amount of essential instructions is low, but there are a lot of exotic instructions (higher arithmetic, trigonometric, etc..). The subset of the language with only the essential instructions should, however, be Turing-complete. The set of instructions is primarily influenced by Assembly language and the memory model by the x87 FPU.

Syntax and Execution
Yes this section bloated a bit, i need to move stuff out here to a section below

Syntax
The instruction pointer is like a turtle walking over the grid of the image. The upper-left pixel of the image is coordinate (1, 1), X increases to the right and Y increases downwards. Each pixel in the image is a discrete location. There are 16 instruction groups assigned to each of the 16 EGA colors (the 16 Windows colors can also be used). Images can however contain other colors, and when these are encountered the closest EGA color is calculated (allowing lossy compression).

Params
Each instruction group (except NOP) needs a parameter (param) to define which instruction to execute or which literal value to take. The parameter is encoded in the area of all 4-connected pixels with the same instruction color. However, when two instructions from the same instruction group are in direct succession, this would cause a conflict, because the area of the entire connected blob would be the same for both instructions. To prevent this, a mechanism is built in to prevent the area of the next and previous instruction from contributing to the area of the current instruction. Instructions which are more than 1 step away, or not on the line of direction of the instruction pointer, are still counted, and this can be exploited as a feature.

Memory
The memory starts empty, and the stack pointer starts at 0. When you push a value, the stack pointer and memory size increases by 1. The stack pointer always points to the top value of the stack.

Data types
Some instructions need a data type more restricted than a float, so here are the conversion rules:
 * Float: any possible value (theoretically unbounded and infinitely accurate; only limited by the implementation)
 * Integer: A float is rounded to the closest integer (0.5 becomes 1).
 * Boolean: Any non-zero value is true. True becomes &minus;1.
 * Sign: &minus;1 means negative, 0 means zero, 1 means positive.

Configuration
There are some configuration flags that modify certain behavior:
 * logbase: The value such that log(logbase) = 1 and exp(1) = logbase. Default = e.
 * angbase: The minimum value such that cos(&#x2124;*angbase) = 1 for any integer &#x2124;. Default = &tau; = 2&pi;
 * iomode: The way values are converted to/from strings when using STDIO. Default = 0.
 * 0 = character mode
 * 1 = float mode
 * 2 = integer mode
 * gfxmode: The way to convert values to/from colors when using GRAPHICS. Default = 0.
 * 0 = 4 BPP, EGA (0..15) in rgbRGB format
 * 1 = 8 BPP, 256 gray shades (0..255)
 * 2 = 6 BPP (0..64) in RRGGBB format
 * 3 = 12 BPP (0..4095) in RRRRGGGGBBBB format
 * 4 = 18 BPP (0..262144) in RRRRRRGGGGGGBBBBBB format
 * 5 = 24 BPP (0..16777215) in RRRRRRRRGGGGGGGGBBBBBBBB format

Error handling
Any instruction that results in an illegal action or state is handled gracefully, using special values or by executing NOP instead. Examples:
 * Popping a value when the stack is empty results in the value 0 and no change to the stack pointer.
 * Writing a value to a non-existing memory location does NOP.
 * Reading a pixel from a non-existing coordinate, e.g. (0, 0), returns 0.
 * Dividing by zero returns Infinity or -Infinity. (NaN can also be generated in some cases)
 * When param is higher than the highest instruction in the group, NOP is executed.

Start and end
The program starts at the first non-NOP instruction on the first line of the image, otherwise in the upper-left pixel. The instruction pointer always starts facing down. When the instruction pointer walks off of any edge of the image, the program halts.

Execution cycle
There are three phases to running a program:
 * Fetch instruction,
 * Execute instruction,
 * Update instruction pointer.

Fetch instruction

 * 1) Look at the color of the pixel under the instruction pointer,
 * 2) Find the closest matching color from the 16-color palette, the index in the palette is the 'instruction group'.
 * 3) Count the area (param) of the instruction, like so:
 * 4) Check if the next and/or previous instructions (in the line of direction of the instruction pointer) have the same color,
 * 5) If so, use a complex algorithm to mark cells from those instructions as unavailable,
 * 6) Apply a generic 4-connected flood fill algorithm to find the area.

Execute instruction
The instruction can update the memory and/or the source image. Therefore execute should commence after fetch to prevent a paradox.

Update instruction pointer

 * Depending on the specific instruction, the instruction pointer may be rotated in one of the four cardinal directions.
 * It then takes one step in the current direction.
 * If the new location does not fall with in the image, execution halts.

Note that the source image might be enlarged by certain instructions, but never by the instruction pointer.

Hello world
"Hello, World!": Note: This is an older version. The brown pixels should be light gray to make it work.

Enlarged, animated (note, the instruction pointer starts at the top-left):

Transcription: PUSH 33 #'!' PUSH 100 #'d' PUSH 108 #'l' PUSH 114 #'r' PUSH 111 #'o' PUSH 119 #'w' PUSH 32 #' ' PUSH 44 #',' PUSH 111 #'o' PUSH 108 #'l' PUSH 108 #'l' PUSH 101 #'e' PUSH 72 #'H' PRINT PRINT PRINT PRINT PRINT PRINT PRINT PRINT PRINT PRINT PRINT PRINT PRINT

Cat
Simple, infinite version:

Version which stops at -1 (EOF):

Mandelbrot
Enlarged and run: edit: it contains a bug. A kudos if you find it.

Brainfuck interpreter
//TODO

Computational class
Turing-complete because it can interpret Brainfuck. This has not been tested yet, but if for some reason it can not interpret Brainfuck, then, by definition, the specification of this language is erroneous and should be fixed.

External resources

 * Source and binaries: https://github.com/Zom-B/Floater