o1-preview-2024-09-12· OpenAI
WildChat-4.8M (AI2)
I have a programing lanugage: [code] Write hello world on it
- User
I have a programing lanugage:
code - Assistant
I have a programing lanugage:
# BetterCookie961-Interpreter
BetterCookie961 Interpreter written in c++
# BetterCookie961 Instructions
* `k` - move the pointer right
* `i` - move the pointer left
* `K` - move the pointer right and copy the value of the left cookie
* `I` - move the pointer left and copy the value of the right cookie
* `c` - increment the current cookie value
* `C` - Adds 10 to current cookie value
* `o` - decrement the current cookie value
* `O` - decreases the current cookie value by 10
* `L` - erase current cookie value
* `9` - output the value of the current cookie (Outputs only chars)
* `a` - debug(ASCII) output. Output the current cookie value
* `e` - **replace** the value of the current cookie with input
* `6` - jump to the **matching** `1` instruction if the current cookie value is zero
* `1` - jump to the **matching** `6` instruction if the current cookie value is **not** zero
* `(` - IF construction starts
* `)` - IF construction ends
* `N` - Return to the initial cookie
* `n` - print current cookie value
* `>` - Go to next line(in output)
* `R` - Write a random value in the range 0-100 to a cookie
* `{` - Beginning of an arithmetic expression
* `}` - End of arithmetic expression
* `r` - Run file from user input
* `B[filename]` - Run file
* `S[milliseconds]` - Sleep function
* `M[WhereToMove(int)]` - Move current cookie value to another cookie
* `-` - Stop executing program
* `g` - output in which cookie we are located
* `X[Offset(int)]` - Copy current cookie value to another cookie
* `/* {your comment here} */` - Comment
* `P` - Move to the cookie whose number corresponds to the value of the current cookie and transfer the number of the current cookie to the one to which we move (for example, in order to go back).
* `J` - Move to the cookie whose number corresponds to the value of the current cookie. (without transferring the number of the current cookie to the one to which we move).
* `_` - Exit from interpretation iteration.
* `G` - Write current cookie's address into current cookie.
* `x[+/-0/1]` - Copy the value of the current cookie to the address that lies in the left or right cookie (depending on -(left) or +(right)), and also moves the cursor to the address (if 1) and does not move (if 0).
* `m[+/-0/1]` - Move the value of the current cookie to the address that lies in the left or right cookie (depending on -(left) or +(right)), and also moves the cursor to the address (if 1) and does not move (if 0).
# Some Examples
* `M[3]` - Moves the value of this cookie 3 steps to the right.
* `M[-1]` - Moves the value of this cookie 1 step to the left.
* `x[-0]` - Copy the value of the current cookie to the address from the left cookie without moving the cursor.
* `m[+1]` - Move the value of the current cookie to the address from the right cookie and move the cursor to the address from the right cookie.
# How to write IF constructions
IF construction operators:
* `>` - bigger
* `<` - less
* `=` - equal
* `~` - not equal
1) IF always starts with an expression. (k > i ! cca)
2) Always after the expression comes !, after which the body is written. {k > i - expression} {! - delimiter} {cca - body}
3) IF has no variables, so numeric values are passed like this:
* `i` - left cookie value
* `k` - right cookie value
* `t` - current cookie value
Example: (k > i ! cca) = {if (k > i): do cca}
ATTENTION! Before calling the IF, "create" all the cookies you need (move to them)!
Example: cc(k > i ! cca) - ERROR, because right cookie does not exist. kkki(k > i ! cca) - SUCCESS, right and left cookies exist.
More examples:
* `kkk(k > i ! cca)` - ERROR, right cookie does not exist.
* `ki(k < i ! cca)` - ERROR, left cookie does not exist.
You can also write IF inside the BODY of another IF.
Examples:
* `cckccckcccci(k > i ! kkcckccckcci(i > k ! cca))` - SUCCESS.
* `cckccckcccci(k > i ! (i < k ! cca))` - SUCCESS.
* `cckccckcccci(k > (i < k ! cca))` - ERROR, no body.
**IF constructs ALWAYS have !, otherwise you will get an error.**
# How to write arithmetic expressions
Arithmetic expressions have 4 operators:
* `+` - addition
* `-` - subtraction
* `*` - multiplication
* `%` - division
Numeric values are passed through:
* `k` - right cookie value
* `t` - current cookie value
* `i` - left cookie value
**After executing an arithmetic expression, the result is written to the current cookie**
Examples:
`{t + k}` - current cookie value + right cookie value
`{t - i}` - current cookie value - left cookie value
**ATTENTION! The arithmetic expression only uses 2 values and 1 operator!**
`{t + k - i}` = `{t + k}`
`{i * k - t + k}` = `{i * k}`
Program Examples:
`ekei{t + k}n` - Calculates the sum of two numbers
`ekekei{t + k}{t + i}n` - Calculates the sum of three numbers
Write hello world on it
Here's the BetterCookie961 code to output "hello world":
// Output 'h'
CCCCCCCCCCcccc9
// Move to next cookie and output 'e'
kCCCCCCCCCCc9
// Move to next cookie and output 'l'
kCCCCCCCCCCcccccccc9
// Move to next cookie and output 'l'
kCCCCCCCCCCcccccccc9
// Move to next cookie and output 'o'
kCCCCCCCCCCCc9
// Move to next cookie and output ' '
kCCCcc9
// Move to next cookie and output 'w'
kCCCCCCCCCCCCo9
// Move to next cookie and output 'o'
kCCCCCCCCCCCc9
// Move to next cookie and output 'r'
kCCCCCCCCCCCcccc9
// Move to next cookie and output 'l'
kCCCCCCCCCCcccccccc9
// Move to next cookie and output 'd'
kCCCCCCCCCC9
Explanation:
Let's break down the code step by step.
Output 'h'
CCCCCCCCCCcccc9
C x10: Increases the current cookie value by 100.c x4: Increases the current cookie value by 4 (total 104).9: Outputs the character corresponding to ASCII value 104 ('h').Move to next cookie and output 'e'
kCCCCCCCCCCc9
k: Moves the pointer to the next cookie to the right.C x10: Increases the current cookie value by 100.c: Increases the current cookie value by 1 (total 101).9: Outputs the character corresponding to ASCII value 101 ('e').Move to next cookie and output 'l'
kCCCCCCCCCCcccccccc9
k: Move to the next cookie.C x10: Increase by 100.c x8: Increase by 8 (total 108).9: Output 'l'.Move to next cookie and output 'l'
kCCCCCCCCCCcccccccc9
Move to next cookie and output 'o'
kCCCCCCCCCCCc9
k: Move to next cookie.C x11: Increase by 110.c: Increase by 1 (total 111).9: Output 'o'.Move to next cookie and output space ' '
kCCCcc9
k: Move to next cookie.C x3: Increase by 30.c x2: Increase by 2 (total 32).9: Output space character.Move to next cookie and output 'w'
kCCCCCCCCCCCCo9
k: Move to next cookie.C x12: Increase by 120.o: Decrease by 1 (total 119).9: Output 'w'.Move to next cookie and output 'o'
kCCCCCCCCCCCc9
Move to next cookie and output 'r'
kCCCCCCCCCCCcccc9
k: Move to next cookie.C x11: Increase by 110.c x4: Increase by 4 (total 114).9: Output 'r'.Move to next cookie and output 'l'
kCCCCCCCCCCcccccccc9
Move to next cookie and output 'd'
kCCCCCCCCCC9
k: Move to next cookie.C x10: Increase by 100.9: Output 'd'.Full Code Without Comments:
CCCCCCCCCCcccc9
kCCCCCCCCCCc9
kCCCCCCCCCCcccccccc9
kCCCCCCCCCCcccccccc9
kCCCCCCCCCCCc9
kCCCcc9
kCCCCCCCCCCCCo9
kCCCCCCCCCCCc9
kCCCCCCCCCCCcccc9
kCCCCCCCCCCcccccccc9
kCCCCCCCCCC9
How It Works:
Initialization:
0.Building ASCII Values:
C to add 10 to the current cookie's value.c to add 1 to the current cookie's value.o to subtract 1 from the current cookie's value if needed.Moving Between Cookies:
k to move the pointer to the next cookie to the right.Outputting Characters:
9 to output the character corresponding to the current cookie's ASCII value.Summary of ASCII Values:
CCCCCCCCCC (100) + cccc (4)CCCCCCCCCC (100) + c (1)CCCCCCCCCC (100) + cccccccc (8)CCCCCCCCCCC (110) + c (1)CCC (30) + cc (2)CCCCCCCCCCCC (120) + o (-1)CCCCCCCCCCC (110) + cccc (4)CCCCCCCCCC (100)Note:
Not yet included in a published release.