The task took two days, just like the original 2KiB game. So I
present "Monster Caves":
Decend downwards, and kill as many monsters as you can. Beware!
Hitting an already dead monster causes it to arise as a nearly
unkillable Lich! How many monsters can you kill before your luck runs
out, or you find the mysterious moving stairwell? Note that the game
doesn't have enough bytes to remember (and print out) your kill total,
so you'll have to do that yourself. You can use the numeric keypad
(with num-lock on) to move about. Move into a monster to attack it,
and move into a stairway to decend another level. If you get stuck in
a disconnected part of a level, try pressing some other keys... you
may just be able to teleport out.
Here is the source code, all 493 bytes of it:
#include<stdlib.h>
#define F(n)for(j=0;j<n;j++)
#define r rand()
int main(){int x,s=46,n,i,j,z=77,l[z];char m[z*s],h[z];initscr();raw
();F(z*s)j[
m]=35;F(s)for(j[l]=i=(r%4+3)*z+(n=r%17*z+r%s+z);n<=i;n+=z)for(x=n;x<=n
+j/2;m[++
x]=s);F(9)l[j][m]=z,j[h]=2;m[*l]=64;*h=5;l[j][m]=62;F(z){x=n=l[i++,i
%=9];if(i)!
i[h]||*l^(n+=r%3+r%3*z+~z)||--*h?0:abort();else{F(25)mvaddnstr(j,i,m
+j*z,z);j=s
-getch();m[n+=j/3*z-j%3+153]^62||main();F(9)l[j+1]^n||--h[j+1]||n
[m]--;}n[m]^s
||(m[l[i]=n]=x[m],x[m]=s);}}
To compile the source code use gcc -O2 source.c -o monster_caves -
lcurses to link with the curses library. Note that one of the tricks
used to shrink the source is to not include the curses header file.
The functions called in the curses library are lucky enough to have
the correct signature without it.
To those interested in some of the tricks used to shrink the source
down so much, I've written an article at http://www.locklessinc.com/articles/512byte_roguelike/
Steven
This is so amazing it maks my head hurt! Well done!
/Bj�rn
--
Are you bored while waiting for the bus? Is your flight delayed?
Play a roguelike on you cellphone while waiting!
http://roguebasin.roguelikedevelopment.org/index.php?title=Dweller
I still prefer the "A journey to hell":
http://cymonsgames.com/ajth/
regards,
Jakub
I still prefer the "A journey to hell":
http://cymonsgames.com/ajth/
The original source code is here:
http://groups.google.com/group/rec.games.roguelike.development/browse_thread/thread/2a44ec42d1f28b91
regards,
Jakub
So,
seeing this is hosted on a commercial site,
how much would one have to pay to have the last Zangband cleaned up
and released ?
T,
I like it better as well. However, if you try to shrink it to half of
its size you'll find that the feature list probably needs to shrink
also. With a limit of 1kib you can create a compact virtual machine,
and then write the game itself in some sort of size-optimized byte-
code. The byte-code lets you add heaps of features for very little
size cost. That was my original plan for this... however, if you add
up the overhead for the virtual machine implementation, there wasn't
quite enough room at 512 bytes to include it and actually have a
working game.
Steven
Fortunately for the world, Angband and its variants are under a non-
commercial license. This means that no one can ever charge money for
them. Unfortunately, that means that if you want your Zangband fix,
you'll need to look at playing with the fork until I get more hobby
time. :-(
Steven
Could you explain how this works? Does #include<stdlib.h> somehow
include the function prototypes for initscr(), raw(), mvaddnstr() and
getch()?
Also: you recursively call main()? Whoa, I didn't even know that was
possible. If you play the game long enough won't you end up with a
stack overflow?
gcc -include stdlib.h -D 'F(n)=for(j=0;j<n;j++)' -D 'r=rand()' -O2
source.c -o monster_caves -lcurses
(Obviously this could be abused to write a deceptively small program.
GCC rejected my attempt at a one-character roguelike (the one
character was of course '@', which was to be redefined with -D) for
being too short, but it will compile the complete program "int main()
{}", which is only 12 characters long.)
I guess this raises an important issue with ultra-small coding
challenges: What are you allowed to #include, and what command-line
statements are allowed during the build process?
You may have missed this during your absence but Angband has
successfully relicensed to the GPL. Some other variants are attempting
to do so as well.
Andrew
In any case even the old Angband license would not prevent you from hiring
a contractor to work on the source.
--
David Damerell <dame...@chiark.greenend.org.uk> Distortion Field!
Yesterday was Thursday, September.
Today is Friday, September.
Tomorrow will be Saturday, September - a weekend.
Thanks, that was what I meant. How much would a Maecenas need to pay
to get it finished ?
T.
> --
> David Damerell <damer...@chiark.greenend.org.uk> Distortion Field!