Brainyay

From Esolang
Jump to navigation Jump to search

BrainYay is a version of Brainf*ck that adds many features, including a stack, and graphics created by user(PhiphiPHIpHi), Phoenix Irwin.

All the original commands from brainf*ck are the same in brainYay except for the [] which are replaced with () respectively PS-sorry about this I just think it looks nicer. Also there are many added commands related to graphics and the stack

for graphics it uses a 400x400 pixel array. with an array for a screen buffer to draw individual double sized pixels to the screen.

additional data structures:

  1. Stack
  2. Pointer functions as a integer variable(:

Also includes basic graphics using SDL2

  1. as of 11/10/2024 the screen buffer has been optimised, now it takes in an input which is the value stored in the pointer, it will only update this pixel when the command "*" is called, to update the whole screen simply hold an invalid (not in range 0-40000) value in pointer_value, the google docs page has been updated, also 1 new command has been added, the final addition was an "anchor" cell set to 255 appended to the very end of the tape of cells, this idea was from the youtuber Truttle1 who was inspired by the video "AI in brainfuck" by Mitxela. (Also I just realised that it won't work because this interpreter uses integers, not bytes, so values can be negative and do not overflow/ underflow at 255)

PPS - I also wrote a c++ interpreter

Commands

The valid commands are:

command list
command pseudo code effect
> move pointer forward
< move pointer back
+ increment the cell at the pointer
- decrement the cell at the pointers
^ sets the value held by the pointer to the value of the cell it is pointing to.
v sets the cell pointed to equal to the pointer's value sets the cell pointed to equal to the pointer's value
l pushes this cells value to the stack.
s retrieves the stack top onto this cell, does not pop the stack
; retrieves input as an integer
, standard brainfuck Unicode value input
: outputs the cells value as a number
. outputs the cells Unicode character
~ Sets the cell to a random number between its current value and the pointers value
t pauses for this cells value seconds
p output the pointer value
# output the item on the top of the stack
output pointer position
2 multiply this cell by 2
/ divide this cell by 2 (rounded down)
% modulo this cell by 2
( jump to the matching ) if this cell is 0
) jump back to the matching ( if this cell is non-zero
[ enter a string to the stack
] stop entering a string
! pop the stack and store the value in the cell pointed too
c clears the stack
? skips the next instruction if the cell at the pointer is equal to the pointer value
_ print the value of the cell as a letter where 1-26 corresponds to a-z, and 27-36 = 0-9
g enter graphics mode initialises a screen and a separate memory tape for it.
G 'n' performs the operation (>, <, +, -, or load(l)) but on the screen buffer
* updates the screen at the location pointer value
@ executes function tape[pointer] as if it were an executable in brainYay(function)
d takes a position in the form of pointer_value(y) and tape[pointer] and draws a white square to that position
{} defines a function with the key tape[pointer]
r resets the pointer to cell 0

Notable mentions Truttle1: Very good content about esolangs, got me into them in the first place (that feels kinda cheesy to say sorry) JuneBug: Youtuber who created an impressive ghost evade game in brainfuck with ascii text graphics, inspired me to add graphics to brainfuck. Silver Takana: has done something similar with adding graphics to brainfuck, but not with a stack and other features.

Implementation

python >= 3.10 implementation on google docs: intepriter

Examples

Hello, world!

[Hello, World!]#

Adding 2 inputs:

;>;<(>+<-)>:

Drawing a pixel to the screen

g [40000]lc [255] (G> Gl -) *

countdown from inputted amount with text

[how long to wait?]#c;s>>>lc>+<(:->t<)c[All Done!]#