G_arD^EN CorUtY@rD

From Esolang
Jump to navigation Jump to search

G_arD^EN CorUtY@rD (from now on referred to as GC) is a 2-dimensional esolang by User:BoundedBeans that doesn't follow traditional flow control standards.

Playfield

There is a playing field which can be as large as desired, but is limited to the bounding box of the program text. Programs must be a rectangle until the end of the first row containing _, in other words, the newline must always be at the same place. The line after _ first appears, this restriction is removed, allowing comments. The rectangle must only contain valid commands, even if they are never reached. This is to encourage programs to look like a nice garden, although this can of course be circumvented by filling all unnecessary parts with ground bricks.

Symbols

The first line is made of of lowercase and capital x's, for the initial data string. Lowercase represents 0, and Uppercase represents 1. If you don't want it to be as long as the total code width, use a K instead of an x or X, then all characters after it in the first row will be ignored.

# - ground bricks. These do nothing except make the program prettier.
_ - end. when the playing field reader encounters one of these, it stops reading the playing field, replacing the rest of the line with ground bricks. Anything after will be treated as a comment. 
+ - sprinkler. Command: enqueues a 1 into the soil if the front of the soil's queue is 1. Put it into the command queue. Set the pointer direction to right.
~ - hose. Command: enqueues a 0 into the soil if the front of the soil's queue is 1. Put it into the command queue. Set the pointer direction to down.
: - heating vent. Command: dequeues a bit from the soil queue. Put it into the command queue. Set the direction to down.
^v>< - Befunge-style arrows, work normally.
= - soil. Holds a collective queue (all soil shares the same queue). If the command queue is not empty, run a command, otherwise do nothing.
X/x - fence. for visual appeal, and also bounces the pointer backwards.
L - chair. the program starts from the uppermost chair, if tied the leftmost chair, beginning moving right.
- - path. If the front bit is 0, change the direction to right, otherwise, change the direction to down.
E - grill. Output the front bit to the output queue. If the output queue after the previous step is 8 bits long, output an ascii character to STDOUT and clear the output queue. Set the direction to right.
T - table. Take a bit of input, insert it into the input queue. If the input queue contains 8 bits, enqueue all 8 bits into the main queue. Set the direction to down.

Note: Grill and Table do not go into the command queue, they act on it no matter what.

If the pointer goes off the playing field, restart at the chair. If the queue is empty, halt.

Computational class

As you can probably tell, this can simulate Bitwise Cyclic Tag, making GC Turing-complete. Simply encode the initial state as the X's at the top, then encode the program. If the command is 11, +, put soil to the right, then the next command to the right of that. If the command is 10, ~, or 0, :, put soil below, then the next command below that.

Note that if the last two commands in Bitwise cyclic tag are 01, this creates a problem with translation since it would have to wrap around the program to get the next number. Luckily, this is simple to fix. We can just take the first bit and append it to the program. However, if that is a 1, it would normally use the next as an argument. So in the case that the last bit is a 1, if the first bit is a zero, then append a zero to the program, if the first bit is a 1, use Befunge-style arrows to make a loop with the opposite parity, like this (this isn't a valid program because of the spaces, only the skeleton):

Lv
 >+=: v<<<<<<
    = v     ^
    >>>+=~  ^
         =  ^
         >>>^

(1101)

Formatting

If you think you would like the programs to be a different shape, or use a more complicated path, you can use arrows. For example, to make the program only use 3 columns, you can do something like this (just the skeleton here):

~
=
:
=
:
=
+=v
v<<
~
=
+=v
v<<
+=v
v<<


This also has extra things that aren't in Bitwise Cyclic Tag, like I/O and some nice extra conditional branching using the path (-).


Let's translate starting position 1001, program 10 11 0 0 0 11 (a full valid program)

XxxXKxxxxx
L~########
====+=###x
=+=:+=###x
====+=#==x
===:+=#==x
====+=#==x
===:+=#==x
====+=####
__________


All we really care about is:

XxxX
L~
 =
 +=:
   =
   :
   =
   :
   =+=
_


Notice how we cleverly hide the guts in a beautiful garden setup? This means that is is relatively easy to read bare programs, but it is impossible to write bare programs. There can be kind of a way to make readable and runnable programs:

XxxXKxxxxx
L~########
#=########
#+=:######
###=######
###:######
###=######
###:######
###=+=####
__________

This is kind of cheating, and I recommend keeping the spirit of GC and writing programs which look nice and are runnable. This may undermine reading, so you could make a readable version that comes with it for open source programs (either using the non-runnable bare style, or the ground bricks style). You might even want to hide your source code; this language makes it super easy to obfuscate for anyone who doesn't trace the exact execution!


Programs

Print "Hi":

XKxxxxxxxxxxxxxxxxxx
L~=~=~=~=~=~=~=~=~=x
L=~=~=~=~=~=~=~=~=~x
#+=~###############x
---=-#-#-#-#-#-#-#-x
---~#-#-#-#-#-#-#-#x
---=-#-#-#-#-#-#-#-x
---+=~#############x
-#-#-==============x
-#-#-~===#=#=#=====x
-#-#-=====###======x
-#-#-~===#####=====x
-#-#-=====###======x
-#-#-~===#=#=#=====x
-#-#-==============x
-#-#-+=+=~:::::::::x
-#-#-#-#-=:::::::::x
-#-#-#-#-+=~-------x
-#-#-#-#-#-=:::::::x
-#-#-#-#-#-~:::::::x
-#-#-#-#-#-=:::::::x
-#-#-#-#-#-+=:-:-:-x
-#-#-#-#-#-#-=:-:-:x
#############>EEEEvx
vvvvvvvvvvvvvvEEEE<x
>^>^>^>^>^>^>>EEEEvx
vvvvvvvvvvvvvvEEEE<x
_-_-_-_-_-_-_-_-_-_


All we care about:

X
L~
 =
 +=~
   =
   ~
   =
   +=~
     =
     ~
     =
     ~
     =
     ~
     =
     +=+=~
         =
         +=~
           =
           ~
           =
           +=:
             =
             >EEEEv
             vEEEE<
             >EEEEv
             vEEEE<

See also