News
Befunge
- Programs
- Compilers
- Interpreters
- Documentation
Doom
Inform
Quake
RISC OS
Misc
Links
Contact
|
Befunge 'troll' programs
Sometime around October/November 2002, I decided to write a self-replicating Befunge program. Not a quine, but a program
which copies itself from one area of fungespace to another. The result was the following series of 'trolls'. I've called
them trolls because at the time I was sure that 'troll' was the name of one of the programs in an age old RISC OS port of
CoreWars. It turns out I was wrong, but the name stuck.
- troll.bf (413 bytes)
The original troll, which can copy itself to one of six locations in befunge-93 space. It's slow, but illustrates the key
processes in a multi-dimensional troll implementation:
- Deciding where to move
- Copying ourself there
- Setting up a route for the IP to travel along in order to reach the new copy
The only real problem with it is that it stores data at a fixed location (the top-left corner of funge space); i.e. it
doesn't modify itself to read/write variables inside the active copy.
- troll2.bf (352 bytes)
Troll1 with all the 'garbage' removed.
- troll3.bf (384 bytes)
A rewrite of the troll. It's still only able to travel to 6 locations but is a faster, smaller, and better implementation
overall.
- troll4.bf (152 bytes)
My first attempt at a 1-dimensional troll. It's still a befunge program, and works by copying itself down through fungespace
one cell at a time. It's fairly slow due to the stringmode backwards-jump technique employed, and travel from copy to copy
is entirely random. If another program was inserted then it may well end up running that instead.
- troll5.bf (157 bytes)
Another 1-dimensional troll, this time it moves properly between the different copies (i.e. from one to the next).
- troll6.bf
Unreleased, unfinished prototype for troll7.
- troll7.bf (1,733 bytes)
A 2D troll which erases the original after making a copy! Fitting it into the 26x12 space was a bit tricky, but I got there
in the end. After the code there are a few notes on how it works. Also take a look at this colour-coded
picture to make understanding the code easier.
- troll8.bf (320 bytes)
A quick attempt at a Befunge-98 troll. It'll copy itself to a random location in fungespace (right up to the +/-2^31 limit),
and partially erase the old copy. At some point I'll probably write a new one which erases itself properly. Might even try
trefunge. Prints out a '1' every time it's about to copy itself so you can tell how fast it's going (Or when it's crashed).
|