RECT4n=GLE
RECT4n=GLE (also known as RECTANGLE) is an esolang created by User:Yayimhere inspired by But Is It Art?, Conway's Game of Life, and 90. The name is based on how memory and all logic is a rectangle AND that like... how are you meant to do something like 4n?
Semantics
A program is a 2d grid of tiles like this:
AA BC CC BBBCCC
The tiles are split up into tilings. These tilings are orthogonally (only vertically and horizontally, not diagonally) connected tiles of the same symbol. So the above grid would be:
AA BC CC BBBCCC
The colored regions are the tilings and the symbols in them are the tiles. As you can see, spaces are not considered tiles. Then the rectangle is created by this logic:
Sorting
We sort the tilings so the tiling with the most tiles is moved all the way to the left, the tiling with the second most tiles is moved next to the first (without vertical overlap), and so on. Ties in size are broken by which tiling has the tiles the furthest down, which tiling has the most tiles at that height, and finally, from left to right.
Generating the rectangle
The rectangle has a fixed width which is the width of the original program including whitespace.
real tiles
Real tiles have this property:
all their neighbours are equal(Wikipedia:Von Neumann neighborhood)
the neighbours of a real tile(these are the actual real tiles) are added to the rectangle first(this operation is applied from the upper left corner of the sorted program to the lower right corner of the sorted program). the state of being a real tile stays for that tile/symbol until the program halts. is also present in the rectangle
imaginary symbols
now we get all the imaginary tiles (that's their name cuz why not) are all the tiles that are not real. yea. each imaginary symbol is added after the real symbols(this operation is applied from the upper left corner of the sorted program to the lower right corner of the sorted program)
the rectangle
the rectangle is the form of memory. the width stays fixed(as mentioned before) so when a symbol is added it starts with one line until the strings has a width of the fixed width. then we add a newline and do this agian un til no more symbols are added
the copying rule
now we have the rectangle generated we apply the copying rule to the rectangle. it works like this:
if a symbol thats imaginary has in the upper left neighbour an real symbol, that imaginary symbol will be copied, and added to the rectangle
and similarly:
if a symbol thats real has in the lower right neighbour an imaginary symbol, that real symbol will be copied, and added to the rectangle
the halting n' stuff
the rectangle returns a bool. this bool is generated like this:
if the width of the last row is equal to the actual width then return true else return false
(and yes the bool is a part of the program productions) and based on this output:
- if true interpret the rectangle as a RECT4n=GLE program
- if false halt
a step by step version
one with no complexity
so first we have the program(tilings colored):
AA BC CC BBBCCC
the we apply rule 1 sorting it by how many tiles there are in each tilings:
C CC BAA CCC BBB
in this case all symbols in the tilings have space neighbours so that step is skipped(i will do another example). now the rectangle gets generated from all the tiles (since none wold be real) and delete the spaces(width = 8):
CCCBAACC CBBB
all these symbols are imaginary so the copying rule wont apply. the rectangle is not complete so it halts
some complexity
heres the program:
A BBBBB AAAB DB ADDDDD
now we sort it:
BBBBB D A B BDDDDDAAA A
as you see i've colored on of the A's cyan. this is because its real. so its neighbours will be added first(and be real):
AAAA
now lets add the other ones(width = 13):
AAAABBBBBDBBD
DDDDA
we apply copying rule where the red are the copies and the green is what had been copied:
AAAABBBBBDBBD DDDDADDDA
still returning false. halt
another example with no colors n' stuff cuz im to tired -_-
program:
ABB ACB AAB
ordered:
A BB A BC AA B
rectangle:
ABB ABC AAB
returns true. so run as a program. ordered:
A BB A B C AA B
generated rectangle:
ABB ABC AAB
this is the same as the one before so it loops forever:)
example programs
ABB ACB AAB
ABB A!B AAB
replace the !
with for
0
and 1
for... well 1
. if 1
it will loops forever and return true forever(which is like boolean 1
), and if 0
it will halt and return a single false(which is like boolean 0
)
External resources
- Implementation at https://github.com/JJRubes/RECT4n-GLE/