CounterScript
CounterScript is a Turing-complete minimal counter-based esolang. It was created in 2026 by Azerty specifically for program enumeration and analysis. CS features a very small instruction set operating over an unbounded set of nonnegative integer variables (counters). What make this esolang interesting is that it takes longer programs to compute chaotic/spaghetti functions, compared to Turing machines.
BBCS(n) is the Busy Beaver function for CounterScript programs.
Definition
A CounterScript program consists of a finite sequence of instructions drawn from three primitives:
- Increment a counter
- Conditional decrement
- While loop
All counters are initialized to 0 and can grow without bound.
The model is closely related to register machines, FRACTRAN and brainfuck. It can simulate Boolfuck, and is therefore Turing-complete.
Instructions
Instructions are executed one by one from left to right.
| Name | Command | Definition |
|---|---|---|
| Increment | A++;
|
Increment counter A by 1 |
| Decrement | A--;
|
Decrement counter A by 1 if A > 0 |
| While loop | while A {...}
|
Executes the loop body while A > 0
|
Macros
In order to improve readability we define the following macros.
| Macro | Definition | Size | Function | |
|---|---|---|---|---|
| Constant Addition | A+=n;
|
increment A by n
|
n
|
A++; repeated n times
|
| Transfer | A>>B*n;
|
increment B by A*n then set A to 0
|
n+2
|
while A {A--; (B++; repeated n times)}
|
Champions
The Busy Beaver function for CounterScript, denoted BBCS(n), returns the largest score a CounterScript program of length n can have when halting.
The score of a program is the maximum value of its counters.
The length of a CounterScript program is defined as the total number of instructions.
By example, A++; B++; while A {A--; C++; C++;} has length 6 and its score is 2.
| n | BBCS(n) | Champion | Counters upon halting |
|---|---|---|---|
| 1 | 1 | A++;
|
1
|
| 2 | 2 | A+=2;
|
2
|
| 3 | 3 | A+=3;
|
3
|
| 4 | 4 | A+=4;
|
4
|
| 5 | 5 | A+=5;
|
5
|
| 6 | 6 | A+=6;
|
6
|
| 7 | 7 | A+=7;
|
7
|
| 8 | 9 | A+=3; A>>B*3;
|
0 9
|
| 9 | 12 | A+=4; A>>B*3;
|
0 12
|
| 10 | 16 | A+=4; A>>B*4;
|
0 16
|
| 11 | 20 | A+=5; A>>B*4;
|
0 20
|
| 12 | ≥ 25 | A+=5; A>>B*5;
|
0 25
|
| 13 | ≥ 42 | A++; while A {A++; while B {A--; B--; C+=2;} C>>B*2; C++;}
|
0 42 1
|
| 14 | ≥ 129 | A++; while A {A++; while B {A--; B--; C+=2;} C>>B*3; C++;}
|
0 129 1
|
| 15 | ≥ 340 | A+=4; while A {A--; B++; B>>C*2; C>>B*2;}
|
0 340 0
|
| 16 | ≥ 1,554 | A+=4; while A {A--; B++; B>>C*3; C>>B*2;}
|
0 1554 0
|
| 17 | ≥ 9,330 | A+=5; while A {A--; B++; B>>C*3; C>>B*2;}
|
0 9330 0
|
| 18 | ≥ 66,429 | A+=5; while A {A--; B++; B>>C*3; C>>B*3;}
|
0 66429 0
|
| 19 | ≥ (3^122 - 3)/2 | A++; while A {A++; while B {A--; B--; C++;} while C {B++; C--; B>>D*3; D>>B;} C++;}
|
0 (3^122-3)/2 1
|
| 20 | ≥ 2^65536 - 2 | A+=4; while A {A--; B++; while B {B--; C++; C>>D*2; D>>C;} C>>B;}
|
0 2^65536-2 0 0
|
| 21 | ≥ 2^2^65536 - 2 | A+=5; while A {A--; B++; while B {B--; C++; C>>D*2; D>>C;} C>>B;}
|
0 2^2^65536-2 0 0
|
| 22 | ≥ 2^^7 - 2 | A+=6; while A {A--; B++; while B {B--; C++; C>>D*2; D>>C;} C>>B;}
|
0 2^^7-2 0 0
|
| 23 | ≥ 2^^8 - 2 | A+=7; while A {A--; B++; while B {B--; C++; C>>D*2; D>>C;} C>>B;}
|
0 2^^8-2 0 0
|
| 24 | ≥ 2^^65536 - 2 | A++; while A {A++; while B {A--; B--; C++;} while C {B++; C--; while B {B--; D++; D>>E*2; E>>D;} D>>B;} C++;}
|
|
| 25 | > 2^^2^^6 | A++; while A {A++; while B {A--; B--; C+=2;} while C {B++; C--; while B {B--; D++; D>>E*2; E>>D;} D>>B;} C++;}
|
|
| 26 | ≥ 2^^2^^65536 - 2 | A+=4; while A {A--; B++; while B {B--; C++; while C {C--; D++; D>>E*2; E>>D;} D>>C;} C>>B;}
|
0 2^^2^^65536-2 0 0 0
|
| 64 | > Graham's number | too large to show, see Discord | |
| 85 | > q(5) (if extant) | too large to show, see Discord |
Cryptids
No cryptids have been found through exhaustive search of a domain. The smallest known cryptid, a Hydra variant, is of length 23.
A++; B++; while B {
while A {
A--; C++; E++;
while D {D--; E--;}
while E {C++; D++; E--;}
}
C>>A; D>>B*3; B--;
}
// start -> (1, 1)
// (2a, b+1) -> (3a, b)
// (2a+1, b) -> (3a+2, b+2)
// (a, 0) -> halt