Friday, 22 May 2009

BF Joust King of the Hill

BF Joust is a capture the flag programming game based on the esoteric Brainf*** programming language. Recently ais523 revised the language and enviroment, setting up a king of the hill tournament.

The game is played between two programs on a tape with a length randomly chosen between 10 and 30 cells. The cells initially contain 0 with the exception of the cells at either end which contain the flag 128.

Each program views the tape with their own flag on the left and the opponent's flag on the right. The object of the game is to find and set the opponents flag to 0 and keep it 0 for two consecutive cycles. If a program's pointer points to a location off the tape, it loses.

Here's a quick summary of the instruction set:

OpDescription
<move the pointer to the left
>move the pointer to the right
+add 1 to the value stored at pointer
-subtract 1 from the value stored at pointer
[jump past the matching ] if the cell at pointer is 0
]jump to instruction after matching [ unless cell at pointer is 0
.no operation, do nothing

The interpreter also understands certain macros. Instructions inside parentheses are repeated a number of times. For example (>-)*4 expands to >->->->-.

For full details see the rules on the BF Joust Wiki page and check the current hill standings. To submit a program to the BF Joust hill, join the channel #esoteric on irc.freenode.net and send a message to egobot:
/msg egobot !bfjoust program_name program_code
It isn't possible to remove a program, but it can be replaced by submitting another with the same name.

Finally, I'll leave you with the code for shortsword the current king of the hill with 100% wins ;-)
(>++>--)*2(>)*6([-[+]]>)*20
The standings:
ID Score Pts Program
18 90.00 18 shortsword.bfjoust
19 71.12 12 stranger.bfjoust
16 69.75 11 scythe_impomatic.bfjoust
1 59.38 9 ais523_attack5.bfjoust
6 42.50 4 ais523_defend5.bfjoust
2 41.50 6 ais523_attackslow.bfjoust
7 38.00 2 asie1.bfjoust
0 37.00 0 ais523_attack2.bfjoust
12 32.38 -1 fool1.bfjoust
9 28.00 0 attack1.bfjoust
4 18.25 -4 ais523_defend0_1.bfjoust
3 16.25 -5 ais523_defend0.bfjoust
11 11.88 -9 ehirdomatic.bfjoust
10 10.50 -7 defend1.bfjoust
5 10.50 -5 ais523_defend1.bfjoust
17 5.62 -4 shield.bfjoust
15 5.62 -9 programname.bfjoust
14 2.62 -10 nop.bfjoust
8 2.62 -8 asie2.bfjoust
20 0.00 0 stuff.bfjoust
13 0.00 0 iwin.bfjoust
Let me know if you have any success with BF Joust.

Saturday, 9 May 2009

CoreLife: Programming in 2 Dimensions!

CoreLife: programming Corewar in 2 dimensions
For a while I've been promising to take a closer look at Dennis Luehring's list of programming games to select a few for further investigation. The list contains over 1500 links in 200 categories!

The first I've chosen is CoreLife, a 2D variant of Corewar by Brent Adams. CoreLife is one of the earliest 2D programming languages, predating Befunge by a few months.

Battles take place on a 100 × 100 memory grid. The outcome of a battle isn't uniquely determined by the initial conditions as there's a random element to the game.

Unfortunately, there's very little information about CoreLife strategies. There are 13 published battle programs. Most of these launch imps or bomb the grid with protected locations. Battle programs are often surrounded by a membrane or shield of protected locations. Despite this CoreLife has the potential to support more complex programs, for example replicators.

I've set myself the challenge of writing a replicator. First I'll attempt to write something linear and if that's successful, a square replicator! Has anyone experimented with CoreLife and if so, did you create a successful program or discover anything interesting?

For more information about programming games, take a look at Steven Robbins' list of programming games or Dennis Luehring's list of programming games.