Toddler

From Esolang
Jump to navigation Jump to search

Toddler is a self modifying language by User:PixelatedStarfish that takes an command in source and replaces it with a randomly chosen valid command. It has a random chance of doing this such that if L is the number of commands in source, than any particular command has a 1 in L chance of being replaced with a random command from the set of valid commands. The language is influenced by Befunge and Entropy.

For each cookie the toddler eats, the odds of random alteration is halved for five moves. If the toddler cannot find a cookie after twenty moves, it will make random alterations and print complaints until they get a cookie.

The Toddler language is derived from Astridec with equivalent operations and memory storage. However, the syntax differs. Toddler is two dimensional. It has five additional operations to guide the instruction pointer around in space. Second, the instruction pointer is a toddler. It behave according to the rules above, and modifies the program as it executes.

A source file is interpreted as a tiled plane with commands mapped to it. The instruction pointer moves from one adjacent tile to the next in a straight line, executing (and sometimes altering) commands it encounters. The executable space is 256 tiles horizontally and unbounded vertically. Commands on the horizontal position 256 and above are ignored.

Commands

Command Desc.
0 Set cell to 0
1 Add one to byte
2 Subtract one from byte
3 Increment cell pointer
4 Decrement cell pointer
5 If cell is 0, turn 90 degrees to the right.
6 If cell is 0, turn 90 degrees to the left.
7 Take input as an ASCII character
8 Print ASCII char
9 Halt
n go north.
s go south.
e go east.
w go west.
x set cell to random value from 0 to 255.
y flip cell value with the next cell value on the tape.
z choose a direction at random (n, s, e, w) and continue.
@ Start.
* A yummy cookie, replaced with a space when eaten.

Complaints

The other parents wonder when you are going to teach your kid some manners. If they do not get cookies they print one of these messages:

*“I want a cookie NOW!”
*“I WANT A COOKIE”
*“No cookie!”
*”Gimme a cookie!”
*”Where is my cookie?”

A Note on Interpretation

This describes a modified interpreter for a given language that runs according to the rules of the Toddler language. It takes source code in a language, transforms it, and runs the language interpreter on the result. Adding an appropriate function to an existing interpreter is sufficient for this purpose. This would make the interpreter a Toddler-friendly interpreter. That said, it is certainly deserving of a place on this wiki despite this characteristic, if not good because of it.

For examples of a Toddler interpreter, Astridec and bf are good choices. The resulting interpreters would run Astridec Toddler and Bf Toddler respectively.