Because I just got one-upped. I thought writing a game in one page of source was good, but the last time I tried to write an RPG in one page of source, I concluded that it probably wasn’t possible.

But now the Temple of the Roguelike is having an ongoing competition for people to write Roguelikes in one kilobyte of source; that’s less than one-fourth the size of a one-page game. Most of the entries so far have been pretty simplistic, but now a true challenger has emerged, called A Journey to Hell.

Here’s the complete source code (compiled on Linux using GCC and curses):

#include <curses.h>
#define W(c)while(c)
#define F(v,h)for(v=0;v<h;v++)
#define D(i)F(y,S)F(x,T){i;}
#define G d[x][y]
#define M d[x+f][y+g]
#define Z(n)n<0?-1:(n>0?1:0)
#define r rand()
int x,y,S=24,T=60,c,d[90][90],L=1,b,k[]=L"$`*$.@?$?>",f,g,z,h,i,l=9,p=20,e=46,
%d L:%d $%d %s",l,p,L,v,L^7?"":"WIN");c=getch();D(G>u&&G<123&&m(Z(f-x),Z(g-y))

Here’s a screenshot.

In this screenshot, the purple ‘@’ is the player (of course). The yellow ‘$’ represents money on the ground. The blue-green ‘?’ represents a chest. The white ‘b’ is a monster; the letter of the monster represents how hard it is to kill, from a (weakest) to z (flee in terror). The red quote mark represents a soul left behind by a monster I just killed; picking this up raises my maximum hit points.

Here’s what that 1K of source gets you:

* Guaranteed traversable levels
* Line-of-sight on the player
* Colored graphics
* Combat with monsters
* Ability to pick up gold and souls (dropped by defeated monsters; powers player up)
* Chests (which can contain gold, a monster or a soul)
* Ability to go down the stairs (generates a new level with tougher monsters)
* Win condition (beat the seventh level to win the game)

Of course his platform gives him a couple of advantages. My library to write colored graphics to the screen and poll the keyboard and mouse under Windows takes up almost 1K of code by itself; the curses library is much more space efficient. Also, GCC supports “default int” on both functions and parameters, meaning that Jakub can declare a function as “m(f,g)” and GCC will assume that ‘m’ is a function that takes two integer parameters, f and g, and returns an int itself. Visual C++ 2005 will not allow such shenanigans (though 2003 was not as strict).

Still, it’s an incredible amount of stuff for less code than it takes to initialize DirectX. I can only imagine what the author, Jakub Wasilewski, could do with the unending expanse a full page of source would provide him.