STACKIE
Paradigm(s) | Imperative |
---|---|
Designed by | Woffur |
Appeared in | 2021 |
Memory system | stack-based |
Dimensions | two-dimensional |
Computational class | Linear bounded automaton |
Reference implementation | TIO |
File extension(s) | N/a |
Stackie is a two-dimensional esoteric programming language originally devised by the Minecraft player Woffur as a game on the DiamondFire Minecraft server. The language is heavily inspired by Befunge. Code is laid out as a two-dimensional grid of blocks, and execution can proceed in any direction of the grid.
The game is accessible on Minecraft server mcdiamondfire.com upon running the command /join 50633
.
Language overview
A Stackie program is laid out on a two-dimensional grid. The grid can either be a grid of ASCII characters (as in the reference implementation) or Minecraft blocks (as in the original game). Each cell on the grid represents a single instruction.
Execution proceeds by means of an instruction pointer. This points to a grid cell on the grid. The instruction pointer has inertia: it can travel to any of the four cardinal directions, and keep traveling that way until an instruction changes the direction. The instruction pointer begins at an Input and begins moving in the Input's direction. Stackie has no jumps farther than two cells, so control flow is done by altering the direction of the program counter, sending it to different literal code paths. The following, for example, is an infinite loop:
>v ^<
Stackie programs store data on a stack.
Instructions
Stackie has the following commands:
Command | Name | Description | Block |
---|---|---|---|
^
|
Redirector | Redirects the pointer to face north. | Magenta Glazed Terracotta |
v
|
Redirector | Redirects the pointer to face south. | Magenta Glazed Terracotta |
<
|
Redirector | Redirects the pointer to face west. | Magenta Glazed Terracotta |
>
|
Redirector | Redirects the pointer to face east. | Magenta Glazed Terracotta |
X
|
End | Halts the program.
The output buffer is not submitted. |
Coal Block |
#
|
Jump | Skips the next block. | Slime Block |
}
|
Rotate Clockwise | Rotates the pointer clockwise. | Orange Wool |
{
|
Rotate Counter Clockwise | Rotates the pointer counter clockwise. | Cyan Wool |
0
|
Push 0 | Pushes a 0 to the stack.
[1,2,3] -> [1,2,3,0] [] -> [0] |
Quartz Block |
.
|
Increment | Increases the top value by 1.
[1,2,3] -> [1,2,4] [0] -> [1] [] -> [] |
Gold Block |
,
|
Decrement | Decreases the top value by 1.
[1,2,3] -> [1,2,2] [0] -> [-1] [] -> [] |
Iron Block |
:
|
Duplicate | Duplicates the top value of the stack.
[1,2,3] -> [1,2,3,3] [1] -> [1,1] [] -> [] |
Lime Terracotta |
\
|
Swap | Swaps the top two values of the stack.
[1,2,3] -> [1,3,2] [5,10] -> [10,5] [5] -> [5] [] -> [] |
Light Blue Terracotta |
$
|
Pop | Pops the top value of the stack.
[1,2,3] -> [1,2] [9] -> [] [] -> [] |
Red Terracotta |
&
|
Over | Copies the second item to the top of the stack.
[1,2,3] -> [1,2,3,2] [1,2] -> [1,2,1] [1] -> [1] [] -> [] |
Cyan Terracotta |
~
|
Reverse | Reverses the entire stack.
[1,2,3] -> [3,2,1] [3] -> [3] [] -> [] |
Purple Terracotta |
L
|
Push Stack Length | Pushes the stack length to the stack.
[1,2,3] -> [1,2,3,3] [10,8,4,2,0] -> [10,8,4,2,0,5] [] -> [0] |
Yellow Terracotta |
+
|
Add | Pops two values from the stack, and pushes their sum.
[1,3,5] -> [1,8] [1,2] -> [3] [1] -> [] [] -> [] |
Oak Planks |
-
|
Subtract | Pops two values from the stack, and pushes their difference.
(The first is subtracted from the second.) [5,3,1] -> [5,2] [2,3] -> [-1] [2] -> [] [] -> [] |
Birch Planks |
*
|
Multiply | Pops two values from the stack, and pushes their product.
[1,3,5] -> [1,15] [2,5] -> [10] [2] -> [] [] -> [] |
Dark Oak Planks |
/
|
Divide | Pops two values from the stack, and pushes their quotient.
(The first is divided from the second, then truncated.) [1,10,2] -> [1,5] [10,3] -> [3] [10,0] -> [] [10] -> [] [] -> [] |
Spruce Planks |
%
|
Modulo | Pops two values from the stack, and pushes their modulus.
(The remainder of the first divided by the second.) [2,10,3] -> [2,1] [10,5] -> [0] [10,0] -> [] [4] -> [] [] -> [] |
Jungle Planks |
n
|
Conditional Redirector | Pops the top value and redirects north if it's 0.
[1,2] -> [1] (No Redirect) [0] -> [] (Redirected) [] -> [] (No Redirect) |
Observer |
u
|
Conditional Redirector | Pops the top value and redirects south if it's 0.
[1,2] -> [1] (No Redirect) [0] -> [] (Redirected) [] -> [] (No Redirect) |
Observer |
(
|
Conditional Redirector | Pops the top value and redirects west if it's 0.
[1,2] -> [1] (No Redirect) [0] -> [] (Redirected) [] -> [] (No Redirect) |
Observer |
)
|
Conditional Redirector | Pops the top value and redirects east if it's 0.
[1,2] -> [1] (No Redirect) [0] -> [] (Redirected) [] -> [] (No Redirect) |
Observer |
!
|
Not | Pops the top value of the stack.
If it was 0, pushes 1. Otherwise, pushes 0. [1,3,5] -> [1,3,0] [2,0] -> [2,1] [0] -> [1] [] -> [] |
Netherite Block |
=
|
Equals | Pops the top two values of the stack.
If they were equal, push 1. Otherwise, push 0. [5,4,4] -> [5,1] [4,3] -> [0] [4] -> [] [] -> [] |
Oak Log |
`
|
Greater Than | Pops the top two values of the stack.
If the second was greater than the first, push 1. Otherwise, push 0. [2,5,4] -> [2,1] [5,5] -> [0] [5,6] -> [0] [5] -> [] [] -> [] |
Spruce Log |
p
|
Print Number | Pops the top value and adds it to the output buffer.
[5,1,4] -> [5,1] / "A" -> "A4" [] -> [] / "A" -> "A" |
Purpur Block |
P
|
Print ASCII | Pops the top value and adds it to the output buffer as ASCII.
[5,1,65] -> [5,1] / "" -> "A" [256] -> [] / "" -> "" [] -> [] / "" -> "" |
Purpur Pillar |
@
|
Submit | Prints the contents of the output buffer, and clears it.
"Hello, World!" -> "" |
Target Block |
M
|
Input | Creates a pointer facing north when activated.
The initial value is [], unless level-defined. |
Dispenser |
W
|
Input | Creates a pointer facing south when activated.
The initial value is [], unless level-defined. |
Dispenser |
[
|
Input | Creates a pointer facing west when activated.
The initial value is [], unless level-defined. |
Dispenser |
]
|
Input | Creates a pointer facing east when activated.
The initial value is [], unless level-defined. |
Dispenser |
Examples
Hello World
>+:.*P0.....:+v :v,P...:P:P,,<: .,>,,,P0....v,* .,, :,. .:, :,: .P, +,P 0,, *,. ]^>^ >.,.@X >v P,. .. ^<+. .* +. ., :. :P :. .>0....::+*:P^: ^....0P:...P:P<