Brainball

From Esolang
Jump to navigation Jump to search

Brainball is an esoteric programming language where numbers are treated like a physical object (the ball) that you push, teleport, clone, or straight-up steal from other cells until it starts yelling ASCII at the screen.

Brainball
Designed by User:FordsTheodore
Appeared in 2026
Computational class Turing-complete
Reference implementation Gist
File extension(s) .bb.txt

Brainball is built on three core ideas:

  1. Numbers are not abstract, they exist somewhere.
  2. If you want a value, you must move it or clone it.
  3. Nothing happens implicitly. Ever. Except for the chicken, but we don't talk about the chicken.
  4. System variables dont count as variables, even though their name has the word "variable"

If the pointer isn’t there, the program doesn’t know and doesn’t care.

Operators
Name Description
! / Checkout Teleport to a cell
? / Step Move directionally by one cell, direction is based on parameter
^ / Write Overwrite the current cell's value, new value is based on parameter
+ / Add Add the current cell's value by N (user parameter)
- / Subtract Subtract the current cell's value by N (user parameter)
= / Clone Clone the current cell's value and move the clone to a new cell (user parameter)
< / Toss Moves a cell and clears the original
> / Echo Prints an ASCII character based on the current cell's value
[] / Cycle Repeat instructions until the condition becomes false
: / Listen Reads user input (ASCII) and sets a cell's value
| / Pipe Create a new pointer (ID starts at 1)
* / Switch Switch to a pointer
# / Destroy Destroy a pointer (do NOT delete pointer 0)
@ / Get Get a cell's value
% / Swap Swap 2 cell's value

Memory Model

  • A finite tape of integer cells, all starting at 0
  • A single pointer that always points to exactly one cell
  • Every instruction operates at the pointer unless a cell index is explicitly specified
  • Negative indices are allowed, just wrapped
  • Cells are 16-bit unsigned integers (0 to 65,535). All mathematical operations wrap modulo 65,536
  • comments exist btw :D

There are no variables (but a system variable called "chicken"), no registers, no stack, and no mercy. Values live in cells and must be physically relocated if you want them elsewhere

Instructions

For the minimal version, see the operators table on the top of the page.

Pointer Movement

  • ?(L) - move the pointer one cell to the left.
  • ?(R) - move the pointer one cell to the right.
  • !(n) - instantly teleport the pointer to cell n.

Teleportation is intentionally powerful and absolutely abusable.

Value Manipulation

  • ^(n) - set the current cell to n. The old value is overwritten and forgotten.
  • +(n) - add n to the current cell.
  • -(n) - subtract n from the current cell.

No implicit incrementing. No shortcuts. Just math.

Data Stuff

  • @(n) - get the value of cell n and sets the value of chicken to that cell's value
  • cell(n) - basically @(n) but doesnt chicken (shocking)

yeah i didnt have any name ideas

Data Transfer

  • <(n) - move the value from cell n into the current cell. The source cell becomes 0
  • =(n) - clone the value from cell n into the current cell. The source cell survives
  • %(n) - swaps the value of the current cell with the value of cell n. No values are destroyed, just traded.

In Brainball, copying and moving are different actions and pretending otherwise is illegal

also if you swap with an empty cell, its effectively a Toss (<) but in reverse. dont think about it too hard, just do it (yes that was a nike reference)

I/O

  • > - output the value in the current cell as an ASCII character
  • :(cell) - read input and store as an ASCII character in a cell

Printing does not destroy the value. Brainball is cruel, but not that cruel

also Reading overwrites the old one

and : returns 0 for EOF

Loops

  • [ ... ](condition) - repeat the loop body until the condition becomes false

Conditions are checked after each iteration (do–while style)

Conditions must reference explicit cells, for example:

(cell(0) > 0)
(cell(3) != 0)

There is no implicit “current cell” keyword. If you want a value, say where it is

Pointer Management

  • | - create a new pointer
  • *(id) - switch to an existing pointer
  • #(id) - destroy a pointer

Brainball will refuse to destroy pointer 0, as this is the kernel pointer.

if you try to delete pointer 0, it wont because it refuses to.

if *(id) references a pointer that does not exist, the interpreter will automatically switch to the highest-indexed pointer currently available.

Checkops

Yes. the lil' conditional thingies. those are called Checkops.

Basic

These are Checkops that exist in almost every programming language (literally).

  • > - Greater than
  • < - Less than
  • >= - Greater than or equal to
  • <= - Less than or equal to
  • == - Equal to
  • != - Not equal to

Junctionables

These Checkops are a bit more rare, but still common.

  • && - Logical AND
  • || - Logical OR
  • ^^ - Logical XOR / Parity Check (Odd)

Example Programs

Bubl Sort

:(10) !(10)-(48)  // Read first digit into Cell 10
:(11) !(11)-(48)  // Read second digit into Cell 11
:(12) !(12)-(48)  // Read third digit into Cell 12
:(13) !(13)-(48)  // Read fourth digit into Cell 10
:(14) !(14)-(48)  // Read fifth digit into Cell 11
:(15) !(15)-(48)  // Read sixth digit into Cell 12

| *(1) !(1) ^(1)

[
 *(1) ^(0) 
 *(0) !(10)
 [ *(0) %(11) *(1) ^(1) ](cell(10) > cell(11))
 *(0) !(11)
 [ *(0) %(12) *(1) ^(1) ](cell(11) > cell(12))
 *(0) !(12)
 [ *(0) %(13) *(1) ^(1) ](cell(12) > cell(13))
 *(0) !(13)
 [ *(0) %(14) *(1) ^(1) ](cell(13) > cell(14))
 *(0) !(14)
 [ *(0) %(15) *(1) ^(1) ](cell(14) > cell(15))
](cell(1) == 1)

!(10) +(48) > ?(R) +(48) > ?(R) +(48) > ?(R) +(48) > ?(R) +(48) > ?(R) +(48) >

Nultiplication

// AAAAAAAAAAAA
!(0)
^(3)

!(1)
^(3)

!(3)
=(0)

[
	!(0)
	+(cell(3))
	!(1)
	-(1)
](cell(1) > 1)

!(2)
=(0)
+(48)
>

Output:

9

Numbers and Hello World

!(0)
^(10)

[
	!(1)
	^(0)
	[
		!(1)
		+(1)
		!(2)
		=(1)
		+(47)
		>
	](cell(1) < cell(0))
	!(0)
	-(1)
](cell(0) > 0)

!(0) ^(72) >         
!(1) ^(101) >        
!(2) ^(108) > >      
!(3) ^(111) >        
!(4) ^(32) >
!(5) ^(87) >
!(3) >
!(6) ^(114) >
!(2) >
!(7) ^(100) >
!(8) ^(33) >

Output:

0123456789012345678012345670123456012345012340123012010Hello World!

Truth Machine

!(0)
:(0)
[
 !(0)
 >
](cell(0) == 49)
!(0)
>

Output:

0

OR

1111111111111111111...

Cat Program

!(0)
:(0)
>

Print Five A’s

!(0)
^(5)

!(1)
^(65)

[
 !(1)
 >
 !(0)
 -(1)
](cell(0) > 0)

Output:

AAAAA

Design Philosophy

  • Data movement is explicit and unavoidable
  • There is no hidden state and no implied context
  • Programs should read like instructions shouted at a very literal machine
  • If something goes wrong, it is almost certainly your fault

Brainball is designed to be easy to reason about and annoying to write in

Notes

  • Although Brainball is categorized as a Brainfuck derivative, it significantly alters the execution model (multiple pointers, teleportation, explicit conditions).
  • Teleportation (!) exists because walking everywhere is boring

Although Brainball natively operates on integers, floating-point numbers can be emulated by explicitly storing and manipulating IEEE-754-like components (sign, exponent, mantissa) within cells. (this has been fact checked)

Compatibility

While Brainball is Turing Complete, it is "higher" on the abstraction ladder than Brainfuck, making it a viable target for a compiler but a difficult source for a decompiler.

Implementation

The online interpreter is at Github.

The implementation of Brainball is available on github as a Gist.

See Also