Duck Duck Goose

From Esolang
Jump to navigation Jump to search

Duck Duck Goose is an esoteric programming language created by User:Vriskanon (inspired by a joke made by Connor Lawman), with function inspired, in part, by Chicken and brainfuck. The only input commands are 'Duck', 'Goose' and '\n'. The code is made up of integer variables called 'duck's, a pointer called the 'goose' and an integer variable that is outside of the circle of ducks called the 'teacher'.

Program entities

Duck
Variable with position in the code. Must have integer value. Starts at 0.
Goose
Non-Variable with ability to become duck (ducks can become geese). Cannot hold any values. Acts as centre of command.
Teacher
A single variable that is not a duck or goose and is not in the circle.

How to use

The first line sets the number of ducks in the code. E.g:

"duck duck duck goose" would create three ducks and a goose in the code. The line must end with goose. There is always exactly one goose.

The ducks and goose are in a circle, meaning that the position of every duck is always relative to the goose.


Further commands follow this format:


N ducks (e.g. "duck duck" would cause N to be two) followed by \n.

OPTIONAL: Y ducks. Some commands require a Y value as well as an N. This is followed with \n.

A blank line causes N or Y (Y if N is already set) to be 0.

Command line. This is a number of ducks (e.g. one for print). End with "goose" and \n.

Examples

The code to print the ASCII character corresponding with the duck two to the left of the goose is:

duck duck #This is 'N'
duck goose #This is the command

The code to add the values of the Ducks one and two to the left of the Goose is:

duck #This is 'N'
duck duck #This is 'Y'
duck duck goose #This is the command

Duck duck goose is not case sensitive. All strings that are not 'duck' and 'goose' are ignored as well as ALL strings after a #. Therefore, the code could look like this:

DuCk ghfhghdgdfhfhdh DUCK
duckfffffffffduckddddddducgooSE&&&&@@

However, for ease of reading it is conventional to code in all lower case with a single space between ducks and geese.

Duck inputs

(Nth duck = Nth duck to the left of the goose.

Yth duck = Yth duck to the left of the goose.)

Number of Ducks Name Requires Description
0 End Ends the program, required at the end of each program.
1 Print N Prints the ASCII character corresponding to the Nth duck. Goose is unaffected.
2 Add N and Y The Goose becomes a Duck with value equal to the Nth Duck plus the Yth Duck. The Nth Duck becomes the goose.
3 Subtract N and Y The Goose becomes a Duck with value equal to the Nth Duck minus the Yth Duck (N-Y). The Nth Duck becomes the Goose.
4 Multiply N and Y The Goose becomes a Duck with value equal to the Nth Duck multiplied by the Yth Duck. The Nth Duck becomes the Goose.
5 Divide N and Y The Goose becomes a Duck with value equal to the Nth Duck integer divided by the Yth Duck (N//Y). The Nth Duck becomes the Goose.
6 Input N The program takes a single character input from the user. The Goose becomes a Duck with that character's ASCII value. The Nth Duck becomes the Goose.
7 Push N The Goose becomes a Duck with value equal to the Nth Duck. The Teacher's value becomes that of the Nth duck. The Nth Duck becomes the Goose.
8 Pop N The Goose becomes a Duck with value equal to the Teacher's value. The Teacher's value becomes 0. The Nth Duck becomes the Goose.
9 Loop Begin N and Y Creates a loop beginning with label Y. When the program gets to this section, if the Nth Duck's value is 0, the program skips to the loop end with the same label. Otherwise, it enters the loop.
10 Loop End N Creates a loop end with label N. If the program is in the loop, loop back to the loop beginning of the same label.
11 Set N and Y The Goose becomes a Duck with value Y. The Nth Duck becomes the Goose.

Sample programs

Hello World

duck duck duck goose
duck
duck duck duck duck duck duck
duck duck duck duck duck duck duck duck duck duck duck goose
duck duck duck
duck duck duck
duck duck duck duck goose
duck
duck
duck duck goose
duck duck duck
duck goose
duck
duck duck duck duck duck duck duck duck duck duck
duck duck duck duck duck duck duck duck duck duck duck goose
duck duck
duck duck
duck duck duck duck duck goose
duck
duck
duck duck duck duck goose
duck
duck duck duck
duck duck goose
duck duck duck
duck goose
duck duck
duck duck duck duck duck duck duck
duck duck duck duck duck duck duck duck duck duck duck goose
duck
duck duck
duck duck goose
duck duck duck
duck goose
duck duck duck
duck goose
duck duck
duck duck duck
duck duck duck duck duck duck duck duck duck duck duck goose
duck
duck duck
duck duck goose
duck duck duck
duck goose
duck duck duck
duck
duck duck duck duck duck goose
duck duck duck
duck
duck duck goose
duck
duck goose
duck duck
duck duck duck
duck duck duck duck duck goose
duck duck duck
duck duck
duck duck duck goose
duck
duck goose
duck
duck duck
duck duck duck goose
duck
duck duck duck
duck duck duck duck goose
duck duck duck
duck goose
duck duck duck
duck
duck duck goose
duck duck
duck
duck duck goose
duck duck
duck goose
duck duck duck
duck
duck duck duck duck duck goose
duck
duck duck duck
duck duck goose
duck duck duck
duck goose
duck duck
duck duck
duck duck goose
duck duck
duck
duck duck duck goose
duck duck
duck goose
duck
duck duck duck duck duck duck duck duck
duck duck duck duck duck duck duck duck duck duck duck goose
duck
duck duck duck
duck duck duck goose
duck duck duck
duck goose
duck duck
duck duck duck
duck duck duck duck duck duck duck duck duck duck duck goose
duck
duck duck
duck duck duck duck duck goose
duck duck duck
duck goose
duck
duck duck duck duck duck duck duck duck duck duck
duck duck duck duck duck duck duck duck duck duck duck goose
duck duck duck
duck goose
goose

Cat program

duck goose
duck
duck duck duck duck duck duck goose
duck

duck duck duck duck duck duck duck duck duck goose
duck
duck goose
duck
duck duck duck duck duck duck goose

duck duck duck duck duck duck duck duck duck duck goose
goose

Truth-machine

duck duck goose
duck
duck duck duck duck duck duck duck
duck duck duck duck duck duck duck duck duck duck duck goose
duck duck
duck duck
duck duck duck duck goose
duck duck
duck
duck duck duck duck duck duck duck duck duck duck duck goose
duck
duck duck
duck duck duck goose
duck
duck duck duck duck duck duck goose
duck
duck duck
duck duck goose
duck duck

duck duck duck duck duck duck duck duck duck goose
duck
duck goose

duck duck duck duck duck duck duck duck duck duck goose
duck
duck goose
goose

External resources