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.
 GGGG
 A DDD EEE FFF GGGG
 DDD EEE FFF GGGG
 B DDD EE F GGGG
 E FF
 C
When sorted becomes this:
 GGGG
 GGGGFFFEEEDDD A
 GGGGFFFEEEDDD
 GGGG F EEDDD B
 FF E
 C
=== Generating the rectangle ===
The rectangle has a fixed width which is the width of the original program including whitespace. The exception is for whitespace trailing at the end of a line. For example:
 AAB
 AB
 ABB
Has a width of 4, but this rectangle:
 AA B
 A B
 A BB
Has a width of 7.
==== Real tiles ====
Real tiles are all the tiles which form a diamond of all the same symbol after sorting:
 R
 R R
 R
For example, for this rectangle program:
 A BB AACCC
 ABBBBAAC C
 ABBBBAACCC
 BB
Here it is after sorting with the real tiles highlighted in cyan:
 BB CCCAAA
 BBBBC CAAA
 BBBBCCCAAA
 BB
The real tiles are added to the new rectangle buffer first, reading left to right, top to bottom. Which tiles are real will be important for the copying step. The new rectangle buffer would look like this after the real tiles have been added:
 BBCABBBBCC
 AABBBBCABB
==== Imaginary tiles ====
All tiles that are not real tiles are imaginary tiles. Imaginary tiles are added to the rectangle buffer after the real tiles. This is also performed left to right, top to bottom. Using the example from the real tiles, after adding the imaginary tiles the rectangle buffer looks like this:
 BBCABBBBCC
 AABBBBCABB
 CCAAACCAA
==== The copying rule ====
Now we apply the copying rule to the rectangle buffer. Any imaginary tile is copied to the end of the buffer if it has a real tile at its upper left corner. Continuing the example here are the real tiles highlighted in cyan and the imaginary tiles that will be copied in magenta:
 BBCABBBBCC
 AABBBBCABB
 CCAAACCAA
Copied tiles can be copied again if they also have a real tile to the upper right in its new position. Therefore this is the rectangle buffer after the copying rule has been applied:
 BBCABBBBCC
 AABBBBCABB
 CCAAACCAAC
 AAACCAAC
==== Halting ====
If the rectangle buffer is a perfect rectangle then it is reinterpretted as a rectangle program. Otherwise, the program halts. The example we have been following is missing 2 tiles from the final line, and so it halts this round.
=== 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 ==
Infinite Loop:
 ABB
 ACB
 AAB
"Truth-machine":
 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)
== adding random programs onto eachother to see if it does anything ==
 ABB
 ACB
 AAB
and
 A BBBBB
 AAAB DB
 ADDDDD
result
 ABB A BBBBB
 ACBAAAB DB
 AAB ADDDDD
program iterations:
 sp=s(p):
 BBBBB A A BB
 D BAAAA BC
 DDDDD A AA B
 re=r(ss):
 v-real tiles
 (AAAA)BBBBB
 AABBDBAAA
 ABCDDDDDA
 AAB
 re=cr(re):
 AAAABBBBB
 AABBDBAAA
 ABCDDDDDA
 AABABBD
it fails. but looks interesting. if i add a Z at the bottom line of program than it becomes:
 AAAABBBBB
 AABBDBAAA
 ABCDDDDDA
 AABABBDZ
so if i alsoe add an X it becomes:
 AAAABBBBB
 AABBDBAAA
 ABCDDDDDA
 AABABBDZX
which then becomes:
 (im stopping here my brain needs to rest)
== External resources ==
* Implementation at https://github.com/JJRubes/RECT4n-GLE/
Category:Languages Category:Two-dimensional languages Category:Implemented