Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/ttulka/chickenfoot

Two-dimensional programming language for chickens ЁЯРФ
https://github.com/ttulka/chickenfoot

2d chicken esolang programming-language two-dimensional

Last synced: 3 months ago
JSON representation

Two-dimensional programming language for chickens ЁЯРФ

Awesome Lists containing this project

README

        

# Chickenfoot

ЁЯРФ Chickenfoot is a two-dimensional programming language for chickens.

Inspired by a chicken tap dance with dominos:

```chickenfoot
тао тао
тао тал тао тал
та╖таИтазтай та╖таМтазтай
та╣ та╝ та╣
та╣ та╝ та╣
та╣ та╝ та╣
та┐та╜та╜та╜таШтаЛтаПтаатам таЪтаЛтаПтавтам
тал тао тал тао
талтап талтап
```

## 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:

```chickenfoot
та┐
```

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

| Col | Rows | Operation | Precedence | Examples |
|:---:|:----:| --------------------- |:----------:|:--------:|
| 2 | A | Increment | 1 | `таП`, `таЛ` |
| 2 | C | Decrement | 1 | `таз`, `таж` |
| 2 | B | Conditional branching | 2 | `таЯ`, `та╖` |
| 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:

| Col | Number of dots | Register | Examples |
|:---:|:--------------:|:--------:|:--------:|
| 1 | 0 | r0 | `таИ`, `таШ` |
| 1 | 1 | r1 | `таЙ`, `таЬ` |
| 1 | 2 | r2 | `таЛ`, `таЭ` |
| 1 | 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.

An example of incrementing *r2* two times:

```chickenfoot
та┐таНтаЛ
```

### Decrement

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

An example of decrementing *r1* two times after
incrementing it three times:

```chickenfoot
та┐таЙтаЙтаЙтабтав
```

### 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 (тЖШ) | `та╖`, `та▒` |

An example of setting *r3* to one if *r2* is greater than three:

```chickenfoot
та┐тагтагтагта│таП
```

### 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:

```chickenfoot
та┐та╜та╜та╜та╜та╝
тал там
тай тао
талтаптаптап
```

## Examples

### No-op program

The simplest valid program:

```chickenfoot
та┐
```

### Infinite loop

Don't try this at home!

```chickenfoot
та┐тап
```

### Truth-machine

If *r0* contains 1, the program sets *r1* to 1:

```chickenfoot
та┐та░таК
```

### Copier

The program copies content of *r0* to *r1*:

```chickenfoot
таотаптаптап
та┐та░таКтаНтаатай
та╝ таотаптап
та╡таИтагтай
```

### Fibonacci sequence

The program takes an index in *r0* and computes the corresponding
Fibonacci number in *r2*:

```chickenfoot
тао
тао тал
та┐та░таЛтаатаШтаата│тагтаМтаПтал
тал та╝
тал та╝ таотап
тал та▓тавтаОтал
тал та╝
тал та╝ таотап
тал та╖тазтаМтал
талтаптап
```

### Addition of two numbers

An alternative version of a program which adds values in *r0* and *r1*
to *r2*:

```chickenfoot
таЯтаЙтазтам
та╣ тао
та╣ талтаптап
та╣
таЪтаЛтаПтавтам
та╣ тао
та╣ талтаптаптап
та╣
таЯтаИтазтам
та╣ тао
та╣ талтаптап
та╣
та┐таШтаОтаПтаатам
тал тао
талтап
```

## Try it

This repository contains a JavaScript interpreter for Chickenfoot.

```sh
npm i chickenfoot
```

It takes source code as the first argument and optionally initial
register values:

```js
const chickenfoot = require('chickenfoot')

// addition of two numbers
const output = chickenfoot(`
тао тао
тао тал тао тал
та╖таИтазтай та╖таМтазтай
та╣ та╝ та╣
та╣ та╝ та╣
та╣ та╝ та╣
та┐таШтаЛтаПтаатам таЪтаЛтаПтавтам
тал тао тал тао
талтап талтап
`,
2, 3) // x=2, y=3

output[0] // 2 (x)
output[1] // 3 (y)
output[2] // 5 (x+y)
output[3] // 0
```

## Development

**Cascadia Code** is the recommended code editor font for Chickenfoot.

### Testing

```sh
npm test
```

## License

[MIT](LICENSE)