Monkeys

Monkeys is an Esoteric programming language by user:david.werecat which is based entirely on the interaction of monkeys.
== About The Language ==
Monkeys was created as a temporary escape from the extensible functionality and fixed programming structure of my previous languages. It was designed to be conceptually simple, thematic and extremely difficult to do anything useful with it. The central idea of the language, as the title suggests, is monkeys and their interactions. Later on in development, I realized that the language was also similar to a board game. The only portion of the language that I didn't come up with was the idea of 'ladders', which was suggested by a friend.
== Instructions ==
=== Language Basics ===
Monkeys is a task based object oriented language where the only type of object is a monkey. The monkeys are numbered 1 through 7, and the program's operations consist of tasks given to each monkey. Each line is formatted such that the line begins with the monkey's number followed by a space, then the name of the action for the monkey to perform. There are no errors in the language, so any invalid/impossible operation or badly formatted line is ignored instead of halting the program. The lines in the program are executed sequentially until the end of the program is reached, or until all bananas have been eaten (this will be explained later in the documentation).
=== The Setup ===
In Monkeys, the basis for storing values is a 10x10 grid. The grid contains 7 monkeys and 14 bananas. Each column is referred to as a 'ladder', and monkeys move by climbing up or down their ladder or moving to another ladder. No two monkeys may occupy the same space, although there can be multiple bananas in a single space. The grid is a limited space; so when a monkey tries to move off one of the edges of the grid, they instead stay where they are. Since the memory of the program is restricted to a finite grid, it cannot be Turing Complete. The grid is initialized as such (where ! represents a banana, and the numbers 1 through 7 represent the monkeys; note that there are also bananas on the spaces that contain monkeys 6 and 7):
 ..!1.!....
 .......2!.
 .........!
 .3.!......
 .......!..
 .!....!...
 ..5.!4....
 ....6...!.
 ......!...
 .7......!.
=== Monkeys ===
As stated previously, the program has seven monkeys to work with, numbered 1 through 7. Each monkey represents an unsigned 8 bit value, starting at zero. If the value goes above 255 or below 0, the value wraps to the opposite bit value (eg. decrementing 0 becomes 255 or incrementing 255 becomes 0). Each monkey has several states based on certain properties that each monkey has. A monkey may pick up and carry a single banana (explained later), be awake or asleep, and can remember a specific position within the program. All monkeys start carrying no bananas, awake and remembering the location of the first line of the program.
=== Movement ===
Monkeys move using the UP, DOWN, LEFT and RIGHT actions. Each movement action causes them to move around the structure of ladders, but only as long as the move is legal. If the movement is legal, the monkey will move to the new space and will have their value incremented by one if the new space is not adjacent to another monkey. If a monkey would go outside of the grid, their movement is canceled and their value is decremented by one. If a monkey tries to move onto a space with another monkey, their movement is canceled and the two monkeys collide. If the other monkey is asleep, they wake up and no further effects occur. If the other monkey is awake, however, the two monkeys interact. If either neither or both monkeys have a banana, both monkey's values are incremented by one. If only one of the monkeys has a banana, then the banana is transferred to the other monkey.
=== Monkey Solo Actions ===
Monkeys may perform several solo actions. Each solo action affects only the monkey performing the action. The first action is LEARN, which causes a key to be read from the console. The ASCII value of the key is stored in the monkey's value. Another related action is YELL, which causes the ASCII character corresponding to the monkey's value to be written to the console. Monkeys can also PLAY, which randomizes their value. The rest of the possible solo actions are based on the mechanics of sleep, bananas and historical memory. This section will only discuss the actions regarding sleep. The SLEEP action causes the monkey to fall asleep, but only if they are not carrying a banana. When a monkey is asleep, they don't respond to commands, except for the WAKE action. When a sleeping monkey receives the WAKE task, the monkey stops sleeping immediately and begins responding to commands again.
=== Bananas ===
Bananas play a large part in the Monkeys language. They allow the emulation of conditional operations, especially since monkeys carrying bananas cannot sleep. The program starts with 14 bananas, which are spread throughout the grid. There can be multiple bananas in a single space, unlike monkeys. The bananas are moved/carried around the grid by the monkeys. If a monkey is given the GRAB command, if there is a banana in the same space as the monkey and the monkey is not already carrying a banana, the monkey will pick up the banana. A monkey can also DROP the banana that they are currently carrying, but will do nothing if they are not carrying a banana. When a monkey is carrying a banana, they can take the action EAT to eat the banana. The banana will no longer exist in the program, leaving the monkey without a banana. If all bananas have been eaten, the program will exit immediately.
=== Historical Markers ===
Another set of solo actions that a monkey can perform are remembering and recalling points in the program. A monkey can store the location of a statement within the program and can cause the program flow to jump back to the location that they currently recall. One of the actions that allow this behavior is the MARK action. This will cause the monkey to recall the location of the current line within the program. A monkey can only remember one location at a time, therefore the previously stored location will be overwritten. In order to move the program flow to the stored location, a monkey can go BACK to that statement. This mechanic can be used to create loops, where the loop is broken by putting the monkey to sleep so that the recollection will not take effect. Since a monkey will remember the location of a single statement, the program flow will not always move backwards when the action is performed.
=== Monkey Group Actions ===
A monkey can also perform group actions, where the action affects the state of all adjacent monkeys. A group action will only affect adjacent monkeys that are not asleep. Each group action corresponds to a basic mathematical operation. A monkey can TEACH, which increments the value of all adjacent monkeys by the value of the monkey performing the action. Another group action is FIGHT, which decrements the value of all adjacent monkeys by the value of the monkey performing the action. When a monkey is given the BOND command, all adjacent monkey's values are multiplied by the value of the monkey performing the action. The final group action is the EGO action, which causes all adjacent monkey's values to be divided by the value of the monkey performing the action.
== Sample Programs ==
=== CAT Program ===
 1 MARK
 1 LEARN
 1 YELL
 1 BACK
== External resources ==
C interpreter and sample program
Old Visual Basic.NET interpreter and sample programs
Category:Languages
Category:Two-dimensional languages
Category:Object-oriented paradigm
Category:2012
Category:Thematic
Category:Implemented