Rhombitrihexagonal

From Esolang
Jump to navigation Jump to search

Hi, I'm 5anz, and this is my 5th esolang (counting brainXXXXXXXXXXx as one), and this one is about the Rhombitrihexagonal (or 3.4.6.4) Tiling, my personal favourite tiling, due to all the shapes it uses in a way that makes a dodecagon. It *IS* recommended you draw on said tiling if you want to make something in this esolang though. Also each number is a 16-bit signed number (ex -2763 => 1111 0101 0011 0101).

Syntax + How it works

First, write all the commands for the triangles, a line break, then all the squares.

The program will add all the triangle commands into the triangle queue, and whenever it sees an empty triangle, take a command off the queue, and put in on that triangle and run the command. This same thing happens with squares. Also you start on a triangle, placing a command.

The program ends when an empty triangle/square, and the queue for the corresponding shape on empty, or you get to the starting triangle.

Commands

Both the triangles and the squares have different purposes, The triangles are for actual programming, and the squares are for control flow. The rest of this section (up to the Triangles sub-section, of course) will explain why I didn't do it the other way around.

Triangles

Note: There is a stack.

Symbol Name Description
0-9 Push Push that digit onto the stack
+ Add Pop the top 2 values from the stack, and add them.
- Subtract Pop the top 2 values, and subtract the second from the first.
* Multiply Pop the top 2 values from the stack, and multiply them.
/ Divide Pop the top 2 values, divide the second from the first, and round it down.
% Mod .
# Number Pop a value from the stack, subtract 48, and push it back on.
a Character Same as Number, but add 48.
, Input Take input as a number, and push it onto the stack.
. Output Pop a value from the stack, and output it.
\ Ignore Ignore the next triangle command, treating it like a no-op
^ Shift up Pop a value from the stack, and place it at the bottom.
v Shift down Pop a value from the bottom of the stack, and push it (at the top).
r Reverse Reverse the stack.
s Store Pop a value from the stack, and place it into the variable.
p Push Push the value of the variable.
: Duplicate Pop a value from the stack, and push it twice.
? Random Push either a 0 or a 1, randomly.
n Count Push the number of times this specific triangle has been touched.
/ Swap Swap the top 2 values on the stack.
; Pop Pop a value from the stack.
~ No-op Does nothing.

Squares

How they work

Squares, unlike Triangles, do not pop from the stack, but rather "grab", which is like popping, but the value stays on the stack. This was done because I felt like needing to duplicate before branching off could get annoying, though if you really need it to be gone, you can still use ; afterwards.

Additionally, squares always either come in mirror-image pairs, or are symmetric.

Mirror Images

Left Right Name Description
< > Arrow Turn in that direction, no matter what.
\ / Lever Turn in that direction, then flip the lever to the other direction (so \ to /, and vice versa).
) ( Curve Turn in that direction relative to what direction it was created in (ex, if you created a left curve from the bottom, and then entered from the top, you'd turn right).
+ - Sign Grab a value from the stack, and if the number is positive (or 0), turn in the said direction (ex if you have 5 and the square command is -, you'd turn right).
0 1 Zero Grab a value from the stack, and if the number is 0, turn in the said direction.
e o Parity Grab a value from the stack, mod it by 2, and if the number is 0, turn in the said direction.

Symmetric

Symbol Name Description
. Sleep Turn in the same direction as the last square (so <<< is equivalent to <..).
x Cross Turn in the opposite direction as the last square (so <>< is the same as <xx).
n Count Turn in the same direction as the last square, and push the number of times this specific square has been touched.
u Go back Turn backwards, in the same direction you entered (so if you turned right into a u, you'd go back, and turn right).
? Random Turn in a random direction.

Example programs

Hello, World!

89*:.56*1--:.7+::..3+:.456+*.356*1-*:.3+.6-:.8-.68*2-.
<xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx

As you can see, Cross is very useful when not dealing with control flow.

Truth Machine

\.,\a#\~~~~~~~;7:*:.
>xxxxxxx1x....xx<.....

This is an example of why you should draw on a Rhombitrihexagonal Tiling.