Gammaplex
Lode Vandevenne's 2004 two-dimensional esoteric language in the Befunge tradition, unusual for its pixel graphics, mouse input and text-input commands, which made games and Mandelbrot renderers possible.
Created by Lode Vandevenne
Gammaplex is an esoteric programming language designed by Lode Vandevenne and first released on 2 August 2004. Like Befunge, it is a two-dimensional language: the program is a grid of single-character instructions, and an instruction pointer moves around the grid north, south, east or west. What sets Gammaplex apart is that its programs don’t just print text. It opens a graphics window and can plot pixels, draw lines, circles and boxes, read the mouse position and buttons, and take typed input. Its programs include a Pong game, painting programs, plasma effects and a Mandelbrot renderer. Vandevenne’s manual describes the aim: Gammaplex “doesn’t try to be obfuscated or hard to use. But that doesn’t make it un-esoteric, on the contrary!”
A note on the catalogue entry. The encyclopedia index lists this language as “Gammaplex, 1987, Procedural, Scientific.” The primary sources do not support any of those values. The language’s own version history dates v0.1 to 2 August 2004. The copyright line reads “2004-2005” (later “2004-2007”). The author’s homepage lists the language as “Gammaplex (2004)”, and the Esolang wiki files it under its 2004 category. Gammaplex is a two-dimensional esoteric language, not a procedural language for scientific computing. Its floating-point maths and trigonometry exist to drive its graphics. No other language called Gammaplex from 1987 could be found.
History & Origins
In 2004 Vandevenne also wrote QuickCG, a small C++/SDL library for pixel graphics and games. The code in the author’s computer-graphics tutorials on lodev.org later required QuickCG to compile. The Gammaplex interpreter is built on QuickCG, and the 2004 source files carry copyright notices for both.
The version history says v0.1 of the language and its interpreter were released on 2 August 2004, “after 2 days of designing and programming it”. Releases came quickly that month:
| Version | Date | Changes |
|---|---|---|
| 0.1 | 2 August 2004 | First release |
| 0.2 | 3 August 2004 | Adds q, Q, f, r, i, C, F (self-modifying code, text and number output, circles), and fixes y |
| 0.3 | 24 August 2004 | Major redesign (not backwards compatible): time anchors, GOSUB/RETURN, stack programs, new decimal-number system, strings, trigonometry, drawing styles, X-prefixed extended commands, and an interpreter menu |
| 0.31 | 26 August 2004 | Negative-number entry, larger register and stack memory, more GOSUB slots, a more precise π |
| 0.32 | 26 July 2005 | Fixes the H/XH colour conversions and adds the Mandelbrot example |
| 0.33 | 31 October 2007 | Rewritten interpreter. The default time-anchor delay changes from 50 ms to 5 ms |
| 0.34 | 14 May 2010 | Bug and compiler-warning fixes (version from the interpreter source header) |
A Linux build was added on 5 September 2004. The C++ source code joined the download on 9 July 2005. The manual was first hosted at a temporary address on the Katholieke Universiteit Leuven student web server. It later moved to members.gamedev.net/lode/projects/esolangs/gammaplex/. Today it lives at lodev.org/esolangs/gammaplex/. The Esolang wiki article was created on 6 June 2005. The Esoteric File Archive keeps a copy of the v0.31-era manual and distribution.
Design Philosophy
Most esoteric languages of the time, whether Befunge-like or brainfuck-like, could only exchange characters with a console. Gammaplex was designed around a graphical screen instead. Every program runs in an SDL window that starts at 256×256 pixels. A command can resize the window, up to a maximum screen buffer of 1600×1200. Text output is drawn onto this screen as 8×8 pixel characters at a pixel position. Nothing appears until the program explicitly redraws the screen with R.
The manual admits that the instruction set grew in a “messy” way and “contains some inconsistensies”. Vandevenne tried to give each instruction “an as memorable character as possible”. C draws a circle, L a line, B a box, P a pixel, M reads the mouse, and p pushes π. By version 0.3 there were more operations than printable ASCII characters. The extra ones became two-character extended instructions, written with an X prefix.
Key Features
The virtual machine
A Gammaplex program can keep data in two places:
- A stack of up to 1,048,576 values. It wraps around, so pushing past the limit overwrites the oldest value.
- 1,048,576 registers of random-access memory. A register pointer (RP) selects the register to read or write:
uanddmove it up and down, and(and)copy values between the selected register and the stack.
All values are floating-point numbers. Commands that need integers, such as & (bitwise AND) or % (modulo), convert their inputs to integers and convert the result back. The instruction grid can be up to 1024×1024 cells. When the instruction pointer leaves one edge of the grid, it reappears at the opposite edge. Execution starts at the top-left cell, or at the last @ in the file if there is one.
Named registers as graphics parameters
The first 13 registers act as the parameters for the drawing commands:
| Register | Meaning |
|---|---|
| 0, 1 | x, y (“position A”) |
| 2, 3, 4 | R, G, B (“color”, white at start) |
| 5 | radius |
| 6, 7 | x2, y2 (“position B”) |
| 8, 9, 10 | R2, G2, B2 (“color2”) |
| 11 | transparency |
| 12 | style |
To draw a circle, a program stores a position, radius and colour in these registers, then runs C (outline) or F (filled). Stack programs make this less tedious. A single } pops several stack values into a preset group of registers. 1a}, for example, pops the top two values into position A. The style register is a bit field. Its bits switch on transparency, multiply blending, dot and line patterns, horizontal or vertical gradients, background colours for text, and “only draw” or “do not draw” masks based on the colour already on screen.
Input and timing
Mpushes the mouse position andmpushes the state of the left and right buttons.I,JandXIpause the program to read a character, a number or a string. Each shows an optional built-in prompt such as “please enter a number:”.tpushes the number of milliseconds since the program started.jis a time anchor. It waits until a set time has passed since the previous anchor, which keeps games playable on fast machines.
Numbers and strings
The digit characters are instructions too. They are designed so that a number such as 256.23 can be written normally, as long as the instruction pointer is moving east. A decimal counter keeps track of where each new digit goes. # ends one number so the next digits start a new one. A space does not, so 256.23 552 pushes the single value 256.23552. If the pointer is moving west, the digits must be written backwards.
Strings work in a similar way. Everything between X" and "X is pushed as character codes. Because the last character ends up on top of the stack, a string is usually reversed with XS before being printed with Xr. The official Hello World program shows the pattern:
| |
The program pushes the string, reverses it (XS), prints it (Xr), and redraws the screen so the text appears (R). E then traps the instruction pointer in an endless loop. The manual explains that E “does the same as ‘><’ would do”.
Control flow and self-modification
Besides the Befunge-style direction arrows ^ > v < and the mirrors / and \, Gammaplex has some control flow that is unusual for a 2D language:
?skips the next instruction if the popped value is zero.;always skips the next instruction.Gis an absolute GOTO to a grid coordinate taken from the stack.XGis a GOSUB, andXgreturns, restoring the pointer’s earlier direction.qreads the character at any grid position, so data such as a game level can be stored in the source code.Qwrites a character, so programs can modify themselves.
The manual suggests always writing GOTO coordinates with three digits (002#035). That leaves room for the numbers to grow as the code is edited and the targets move.
Maths
Alongside basic arithmetic and bitwise operations, there are commands for square root, cosine, π, rounding and random numbers. One extended command, XT, provides 31 numbered functions. It covers all 24 trigonometric and hyperbolic functions and their inverses, plus exp, ln, a Gaussian, sign, atan2 and logarithms to any base. H and XH convert colours between HSV and RGB.
Evolution
Gammaplex took most of its shape in its first month. Version 0.3, released three weeks after the first one, was a deliberate break with the original design. The version history says “backwards compatibility is lost, but the pain of this is kept to a minimum”. After 0.31, the language barely changed. Later releases focused on the interpreter.
The largest of these releases was a rewrite in October 2007. According to the source code’s changelog, the rewrite used a new version of QuickCG and became “more than 10x faster by not handling SDL events each frame”. The only benchmark the author gives is the bundled Mandelbrot example on the author’s own machine (the hardware is not stated). The manual says it now finishes “in a few seconds, instead of after minutes”. The speed-up had a side effect: Tron3k’s Pong game had no timing control and became too fast to play. Vandevenne modified it to use time anchors and shipped the original as tron3kpong_old.txt. The last release, in May 2010, fixed reported bugs and compiler warnings. The download notes that only the source code and the Linux binary were updated; the Windows executable remained the 2007 build.
Vandevenne’s next language, Deltaplex (listed on the author’s homepage as 2006), was designed as Gammaplex’s successor. Its code is read from a PNG image instead of a text file, so that textures can be stored in the program, and it draws 3D graphics with OpenGL. Esolang wiki user poiuy_qwert, who wrote several Gammaplex example programs, also created two variants of it: Omegaplex (Esolang article created in 2006) and Zetaplex (2007).
Current Relevance
Gammaplex has had no new releases since 2010. Vandevenne’s site still hosts the manual and a gammaplex.zip download, and the Esoteric File Archive keeps an earlier copy. The download contains:
- the C++ source code, which the manual says compiles with
g++ *.cpp -lSDL -O3; - a Bloodshed Dev-C++ project file for Windows;
- a Windows
.exewithSDL.dll, and a Linux ELF binary; - the example programs.
The code uses the old SDL 1.x API (#include <SDL/SDL.h>). Building it on a current system probably needs an SDL 1.2 compatibility layer, but this has not been tested for this page. There is no official or community Docker image.
The manual’s list of open challenges was still there in the 2010 version: a prime-number program, the Game of Life, an adventure game, a spinning 3D wireframe cube, Tic-Tac-Toe and a Tetris-style game. The list also asks for a “proof that Gammaplex is or isn’t Turing Complete”. The opening of the same manual says the language is Turing complete “if it would have an infinite instruction array”. The Esolang wiki files it as Turing complete. Both statements are informal; no published proof was found.
Why It Matters
Gammaplex is an early example of an esoteric language that treated graphics and interactivity as first-class features. Most of its contemporaries were limited to a text console. Within about a year of the first release, the distribution included a Pong game by Tron3k, two painting programs and Vandevenne’s own Mandelbrot renderer. A cryptic two-dimensional instruction grid turned out to be a usable medium for small interactive programs. Gammaplex also started a small family of related languages: its own successor, Deltaplex, and the community variants Omegaplex and Zetaplex. Its design keeps Befunge’s two-dimensional flow but adds a large practical instruction set, without the deliberate obscurity of most esoteric languages.
Timeline
Notable Uses & Legacy
Pong by Tron3k
A one-player Pong game against a computer opponent, controlled with the mouse. Vandevenne's manual calls it the first game made in Gammaplex. In 2007 Vandevenne edited it to use time anchors, because the faster new interpreter made it run too fast to play
Mandelbrot renderer
Vandevenne's mand.txt example (added in v0.32) renders the Mandelbrot set in colour. It uses GOSUB for the per-pixel iteration and the HSV-to-RGB command to colour each pixel
Esolang wiki example programs
The Esolang wiki article collects programs by poiuy_qwert, including a quine (which uses the q command), an XOR texture, a plasma effect and a digital root calculator
Multi-language polyglot
A polyglot by Marinus Oosters, included in the official distribution, prints 'HI' in Gammaplex and in a number of other languages from the same source file