Chickenfoot

From Esolang
Jump to navigation Jump to search
Chickenfoot
Paradigm(s) imperative
Designed by User:Ttulka
Appeared in 2023
Memory system Cell-based
Dimensions two-dimensional
Computational class Turing complete
Major implementations Interpreter in JavaScript
Influenced by Minsky machine
Influenced None
File extension(s) .🐔

Chickenfoot is a two-dimensional programming language inspired by a chicken tap dance with dominos, where the chaotic rhythms of the moonlit barnyard translate into code and feathers.

How it works

The program is equipped with four registers further referenced as r0, r1, r2, and r3. Each register holds an unbounded integer value.

The execution starts at the begin command and continues left-to-right as the default. The flow can be altered by the conditional branching command or by a handful of flow commands. In this way, loops can be created.

The program halts when a whitespace is read.

Commands

Each command consists of a single symbol of the Braille 6-dot patterns:

  1 2
A o o
B o o
C o o

Braille symbols that do not fit any command definition and all other symbols are interpreted as whitespaces.

The begin command indicates the beginning of the program. Each program must include exactly one begin command:

Except for the begin command, dots in the second column indicate the operation:

Rows Operation Precedence Examples
A Increment 1 ,
C Decrement 1 ,
B Conditional branching 2 ,
A+C Flow 3 ,

Operations conditional branching and flow combine other dots as additional parameters.

For arithmetic commands increment, decrement, and the control flow command conditional branching, the number of dots in the first column indicates the index of a register to work with:

Number of dots Register Examples
0 r0 ,
1 r1 ,
2 r2 ,
3 r3 ,

The vertical position of dots in the column is irrelevant and fully aesthetics-driven. The following commands are equivalent: , , .

Increment

The increment command increases the value of the selected register.

Increment r2 two times:

⠿⠍⠋

Decrement

The decrement command decreases the value of the selected register if its current value is greater than zero.

Decrement r1 two times after incrementing it three times:

⠿⠉⠉⠉⠡⠢

Conditional branching

Conditional branching changes the control flow based on the current value of the selected register. If the value equals zero, the flow branches; otherwise, it continues left-to-right.

The command always comes with another dot in the second row, which indicates the direction of the control flow in the case when the value of the selected register is equal to zero:

Rows Zero flow direction Examples
B+A Northeast ,
B+C Southeast ,

Set r3 to one if r2 is greater than three:

⠿⠣⠣⠣⠳⠏

Flow

The flow operation changes the control flow of the program.

The number of dots in the first column indicates the direction:

Command Flow direction
North
Northeast
East
Southeast
South
Southwest
West
Northwest

A flow into the chicken hole:

⠿⠽⠽⠽⠽⠼
 ⠫     ⠬
 ⠩     ⠮
  ⠫⠯⠯⠯

Examples

(As various editors may not consistently display Braille symbols at the same size, Cascadia Code is the recommended font for Chickenfoot.)

No-op program

The simplest valid program:

Infinite loop

The smallest chicken hole:

⠿⠯

Truth-machine

If r0 contains 1, it sets r1 to 1:

 ⠿⠰⠊

Copier

It copies content of r0 to r1:

  ⠮⠯⠯⠯
⠿⠰⠊⠍⠠⠩
  ⠼ ⠮⠯⠯
   ⠵⠈⠣⠩

Fibonacci sequence

It takes an index in r0 and computes the corresponding Fibonacci number in r2:

        ⠮
       ⠮ ⠫
⠿⠰⠋⠠⠘⠠⠳⠣⠌⠏⠫
     ⠫ ⠼
      ⠫ ⠼ ⠮⠯
       ⠫ ⠲⠢⠎⠫
        ⠫ ⠼
         ⠫ ⠼ ⠮⠯
          ⠫ ⠷⠧⠌⠫
           ⠫⠯⠯

Addition of two numbers

It adds values in r0 and r1 to r2:

       ⠮       ⠮
      ⠮ ⠫     ⠮ ⠫
     ⠷⠈⠧⠩    ⠷⠌⠧⠩
    ⠹ ⠼     ⠹
   ⠹   ⠼   ⠹
  ⠹     ⠼ ⠹
⠿⠘⠋⠏⠠⠬   ⠚⠋⠏⠢⠬
  ⠫  ⠮    ⠫  ⠮
   ⠫⠯      ⠫⠯

Turing completeness

Chickenfoot is evidently Turing-complete as any Minsky machine can be translated into Chickenfoot:

Minsky machine Chickenfoot
INC
JZDEC ⠘⠠

Four unbounded registers are also sufficient as a Minsky machine has been demonstrated to be Turing equivalent using only two registers (or even a single one when Gödel numbering is employed).

External resources