Poohbear

From Esolang
Jump to navigation Jump to search

Poohbear is a cell-based language largely inspired by brainfuck. It has a maximum integer value of 255, and 30,000 cells. The original intention of Poohbear was to be able to send messages that would, to most, be completely indecipherable.

Commands

Command Definition
+ Add 1 to the current cell
- Subtract 1 from the current cell
> Move the cell pointer 1 space to the right
< Move the cell pointer 1 space to the left
c "Copy" the current cell
p Paste the "copied" cell into the current cell
W While loop - While the current cell is not equal to 0
E Closing character for loops
P Output the current cell's value as ascii
N Output the current cell's value as an integer
T Multiply the current cell by 2
Q Square the current cell
U Square root the current cell's value
L Add 2 to the current cell
I Subtract 2 from the current cell
V Divide the current cell by 2
A Add the copied value to the current cell's value
B Subtract the copied value from the current cell's value
Y Multiply the current cell's value by the copied value
D Divide the current cell's value by the copied value.

Examples

Although there are many ways to do the same thing, here are some examples. The following is a Hello World Program:

+LTQTP>LL+TQ+P>LLT-c<APP>IIc<AP>I->+LLT+TTP<+LLTLc>BP>+LQQLLLP<<<PL+PIIIPIIIIP>>>>LLQT+P

There's nothing too complicated in this example. A program that outputs all printable ASCII characters:

+LTQIIWP+E

This program starts at a value of 32, the first printable ASCII character. Then it increments by 1 every loop until it reaches 0 and the loop closes. A program that prints numbers from 1-255:

+LTQII>+WN<P>+E

The first section stores 32, which in ASCII is a space. Then it adds one to the next cell, and goes through all the numbers until it wraps back to zero and the loop closes.

Interpreters

An interpreter for Poohbear was written in C, which worked by rewriting the input program and converting it to its C equivalent, and then compiling and running it. That interpreter can be found here.. To run a .pb file, open the command prompt in the folder, and type poohbear file.pb.