Cratefuck

From Esolang
Jump to navigation Jump to search

Cratefuck is an esoteric programming language created by User:DigitalDetective47 where you have a limited amount of data markers to use.

Program structure

Data in Cratefuck is stored in a warehouse consisting of a linear series of rooms. The warehouse is unbounded on the right only. Each room can store crates inside of it. Crates can be moved around using the crane, which can pick up one crate at a time. The warehouse starts with 256 crates in room 0, and all other rooms are empty.

Syntax

Cratefuck reads commands in order, ignoring all unrecognized commands. A table of commands is below:

Command Meaning
< Move the crane one room to the left. If the crane is in room 0, do nothing.
> Move the crane one room to the right.
* If the crane is holding a crate, drop it in the room that the crane is currently in. If the crane is not holding a crate and the room that the crate is in is not empty, pick up a crate from that room. If the crane is not holding a crate and its room is empty, do nothing.
. Print the Unicode character corresponding to the number of crates in the room that the crane is in. This number excludes the crate the crane is holding, if any. Characters 10 and 13 are both newline characters.
[ Jump execution forward past the matching ] if the crane is not holding a crate.
] Jump execution back to the matching [.

A program with mismatched brackets is invalid and should not run.

Examples

Hello, world!

*[>*<*>>*<<*>>>*<<<*>>>>*<<<<*] Make 4 stacks of 64 in rooms 1, 2, 3, & 4; (0, 64, 64, 64, 64
>>>>*<*>*<*>*<*>*<*>*<*>*<*>*<*>*<*. Manually move 8 crates from room 4 to room 3 and print "H"; (0, 64, 64, 72, 56
>*[>*<*>>*<<*] Split the remaining 56 crates in room 4 into 2 stacks of 28 in rooms 5 & 6; (0, 64, 64, 72, 0, 28, 28
>>*[<<<*>>>*] Move all 28 crates from room 6 into room 3; (0, 64, 64, 100, 0, 28, 0
<*<<*. Move 1 crate from room 5 to room 3 and print "e"; (0, 64, 64, 101, 0, 27, 0
<*>*<*>*<*>*<*>*<*>*<*>*<*>*.. Move 7 crates from room 2 to room 3 and print "ll"; (0, 64, 57, 108, 0, 27, 0
<*>*<*>*<*>*. Move 3 more crates from room 2 to room 3 and print "o"; (0, 64, 54, 111, 0, 27, 0
<*<*>*<*>*<*>*<*>*<*>*<*>*<*>*<*>*<*>*<*>. Move 10 crates from room 2 to room 1 and print ","; (0, 74, 44, 111, 0, 27, 0
>*>>*<<*>>*<<*>>*<<*>>*<<*>>*. Move 5 crates from room 3 to room 5 and print " "; (0, 74, 44, 106, 0, 32, 0
<<<<*[>*<*]>>*<*. Move 74 crates from room 1 and 1 crate from room 3 to room 2 and print "w"; (0, 0, 119, 105, 0, 32, 0
*>*<*>*<*>*<*>*<*>*<*>*. Move 6 crates from room 2 to room 3 and print "o"; (0, 0, 113, 111, 0, 32, 0
*<*. Move 1 crate from room 3 to room 2 and print "r"; (0, 0, 114, 110, 0, 32, 0
>*<*>*<*>. Move 2 crates from room 3 to room 2 and print "l"; (0, 0, 116, 108, 0, 32, 0
*<*>*<*>*<*>*<*>*<*>*<*>*<*>*. Move 7 crates from room 3 to room 2, grab an 8th crate from room 3, and print "d"; (0, 0, 123, 100, 0, 32, 0
>>*. Move the 8th crate to room 5 and print "!"; (0, 0, 123, 100, 0, 33, 0

Without comments or line breaks, it looks like this:

*[>*<*>>*<<*>>>*<<<*>>>>*<<<<*]>>>>*<*>*<*>*<*>*<*>*<*>*<*>*<*>*<*.>*[>*<*>>*<<*]>>*[<<<*>>>*]<*<<*.<*>*<*>*<*>*<*>*<*>*<*>*<*>*..<*>*<*>*<*>*.<*<*>*<*>*<*>*<*>*<*>*<*>*<*>*<*>*<*>*<*>.>*>>*<<*>>*<<*>>*<<*>>*<<*>>*.<<<<*[>*<*]>>*<*.*>*<*>*<*>*<*>*<*>*<*>*.*<*.>*<*>*<*>.*<*>*<*>*<*>*<*>*<*>*<*>*<*>*.>>*.

Infinite loop

*[]

Truth-machine

>*[>>>>>*<<<<<<*[>*<*>>*<<*>>>*<<<*>>>>*<<<<*>>>>>*<<<<<*]>*<*>*[.]]<*>>>>>>*<<<<<<*[>*<*>>*<<*>>>*<<<*>>>>*<<<<*>>>>>*<<<<<*]>*<*>*<*>*.

The program takes the number of crates in room 1 as its input. To input a 0, simply run the program as‐is. To input a 1, prepend *>*< to the program.

TOGA and Smallfuck machines

See the Talk page.

Implementations