Gmail Calendar Documents Reader Web more »
Recently Visited Groups | Help | Sign in
Google Groups Home
1/2KiB roguelike
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  13 messages - Collapse all  -  Translate all to Translated (View all originals)
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
sfuerst  
View profile  
 More options Sep 21, 12:28 pm
Newsgroups: rec.games.roguelike.development
From: sfuerst <svfue...@gmail.com>
Date: Mon, 21 Sep 2009 09:28:45 -0700 (PDT)
Local: Mon, Sep 21 2009 12:28 pm
Subject: 1/2KiB roguelike
Hello, back in 2006 I made the 2KiB roguelike, the first of the really
small roguelikes.  I then left the roguelike world for a few years.  A
few weeks ago, I was making a search for my old code, and noticed that
others have taken up the challenge, and there now are a few 1KiB
roguelikes, half the size of the original.  Not to be out done, I then
endeavoured to make another halving, and create a roguelike that was
less than 512 bytes of source code.

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


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Björn Ritzl  
View profile  
 More options Sep 21, 3:42 pm
Newsgroups: rec.games.roguelike.development
From: Björn Ritzl <bjorn.REMOVETHISri...@gmail.com>
Date: Mon, 21 Sep 2009 21:42:37 +0200
Local: Mon, Sep 21 2009 3:42 pm
Subject: Re: 1/2KiB roguelike
sfuerst skrev:

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


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Jakub Debski  
View profile  
 More options Sep 21, 3:52 pm
Newsgroups: rec.games.roguelike.development
From: Jakub Debski <debski.ja...@wp.pl>
Date: Mon, 21 Sep 2009 21:52:36 +0200
Local: Mon, Sep 21 2009 3:52 pm
Subject: Re: 1/2KiB roguelike
on 2009-09-21, Björn Ritzl supposed :

> This is so amazing it maks my head hurt! Well done!

I still prefer the "A journey to hell":
http://cymonsgames.com/ajth/

regards,
Jakub


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Jakub Debski  
View profile  
 More options Sep 21, 3:54 pm
Newsgroups: rec.games.roguelike.development
From: Jakub Debski <debski.ja...@wp.pl>
Date: Mon, 21 Sep 2009 21:54:31 +0200
Local: Mon, Sep 21 2009 3:54 pm
Subject: Re: 1/2KiB roguelike
(supersedes <mn.ad207d99f19f8573.68...@wp.pl>)
on 2009-09-21, Björn Ritzl supposed :

> This is so amazing it maks my head hurt! Well done!

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...

regards,
Jakub


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
konijn_  
View profile  
 More options Sep 21, 5:21 pm
Newsgroups: rec.games.roguelike.development
From: konijn_ <kon...@gmail.com>
Date: Mon, 21 Sep 2009 14:21:12 -0700 (PDT)
Local: Mon, Sep 21 2009 5:21 pm
Subject: Re: 1/2KiB roguelike
On Sep 21, 12:28 pm, sfuerst <svfue...@gmail.com> wrote:

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,


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
sfuerst  
View profile  
 More options Sep 22, 12:35 pm
Newsgroups: rec.games.roguelike.development
From: sfuerst <svfue...@gmail.com>
Date: Tue, 22 Sep 2009 09:35:32 -0700 (PDT)
Local: Tues, Sep 22 2009 12:35 pm
Subject: Re: 1/2KiB roguelike
On Sep 21, 12:52 pm, Jakub Debski <debski.ja...@wp.pl> wrote:

> on 2009-09-21, Björn Ritzl supposed :

> > This is so amazing it maks my head hurt! Well done!

> I still prefer the "A journey to hell":http://cymonsgames.com/ajth/

> regards,
> Jakub

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


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
sfuerst  
View profile  
 More options Sep 22, 12:40 pm
Newsgroups: rec.games.roguelike.development
From: sfuerst <svfue...@gmail.com>
Date: Tue, 22 Sep 2009 09:40:48 -0700 (PDT)
Local: Tues, Sep 22 2009 12:40 pm
Subject: Re: 1/2KiB roguelike
On Sep 21, 2:21 pm, konijn_ <kon...@gmail.com> wrote:

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


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Gelatinous Mutant Coconut  
View profile  
 More options Sep 22, 3:41 pm
Newsgroups: rec.games.roguelike.development
From: Gelatinous Mutant Coconut <gelatinousmutantcoco...@gmail.com>
Date: Tue, 22 Sep 2009 12:41:55 -0700 (PDT)
Local: Tues, Sep 22 2009 3:41 pm
Subject: Re: 1/2KiB roguelike
On Sep 21, 12:28 pm, sfuerst <svfue...@gmail.com> wrote:

> 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.

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?


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Gelatinous Mutant Coconut  
View profile  
 More options Sep 22, 4:40 pm
Newsgroups: rec.games.roguelike.development
From: Gelatinous Mutant Coconut <gelatinousmutantcoco...@gmail.com>
Date: Tue, 22 Sep 2009 13:40:14 -0700 (PDT)
Local: Tues, Sep 22 2009 4:40 pm
Subject: Re: 1/2KiB roguelike
Since you are using GCC, you can save even more by removing your
#define and #include lines and changing your compile command to:

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?


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Elig  
View profile  
 More options Sep 23, 5:54 pm
Newsgroups: rec.games.roguelike.development
From: Elig <eligz...@gmail.com>
Date: Wed, 23 Sep 2009 14:54:56 -0700 (PDT)
Local: Wed, Sep 23 2009 5:54 pm
Subject: Re: 1/2KiB roguelike
Fantastic job! I might try to do this.. I tried to write a small
roguelike by line count, but it seemed to always require over 25 lines
unless I was putting lines ontop of each other. But if you go by the
bytes of the source, that seems like a much more reasonable metric
than line number. Great job!

    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Andrew Doull  
View profile  
 More options Sep 24, 7:24 am
Newsgroups: rec.games.roguelike.development
From: Andrew Doull <andrewdo...@gmail.com>
Date: Thu, 24 Sep 2009 04:24:33 -0700 (PDT)
Local: Thurs, Sep 24 2009 7:24 am
Subject: Re: 1/2KiB roguelike
On Sep 23, 2:40 am, sfuerst <svfue...@gmail.com> wrote:

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


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
David Damerell  
View profile  
 More options Sep 24, 10:37 am
Newsgroups: rec.games.roguelike.development
From: David Damerell <damer...@chiark.greenend.org.uk>
Date: 24 Sep 2009 15:37:03 +0100 (BST)
Local: Thurs, Sep 24 2009 10:37 am
Subject: Re: 1/2KiB roguelike
Quoting  Andrew Doull  <andrewdo...@gmail.com>:

>On Sep 23, 2:40=A0am, sfuerst <svfue...@gmail.com> wrote:
>>On Sep 21, 2:21=A0pm, konijn_ <kon...@gmail.com> wrote:
>>>seeing this is hosted on a commercial site,
>>>how much would one have to pay to have the last Zangband cleaned up
>>>and released ?
>>Fortunately for the world, Angband and its variants are under a non-
>>commercial license. =A0 This means that no one can ever charge money for
>>them.
>You may have missed this during your absence but Angband has
>successfully relicensed to the GPL.

In any case even the old Angband license would not prevent you from hiring
a contractor to work on the source.
--
David Damerell <damer...@chiark.greenend.org.uk> Distortion Field!
Yesterday was Thursday, September.
Today is Friday, September.
Tomorrow will be Saturday, September - a weekend.

    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
konijn_  
View profile  
 More options Sep 24, 1:58 pm
Newsgroups: rec.games.roguelike.development
From: konijn_ <kon...@gmail.com>
Date: Thu, 24 Sep 2009 10:58:43 -0700 (PDT)
Local: Thurs, Sep 24 2009 1:58 pm
Subject: Re: 1/2KiB roguelike
On Sep 24, 10:37 am, David Damerell <damer...@chiark.greenend.org.uk>
wrote:

> Quoting  Andrew Doull  <andrewdo...@gmail.com>:

> >On Sep 23, 2:40=A0am, sfuerst <svfue...@gmail.com> wrote:
> >>On Sep 21, 2:21=A0pm, konijn_ <kon...@gmail.com> wrote:
> >>>seeing this is hosted on a commercial site,
> >>>how much would one have to pay to have the last Zangband cleaned up
> >>>and released ?
> >>Fortunately for the world, Angband and its variants are under a non-
> >>commercial license. =A0 This means that no one can ever charge money for
> >>them.
> >You may have missed this during your absence but Angband has
> >successfully relicensed to the GPL.

> In any case even the old Angband license would not prevent you from hiring
> a contractor to work on the source.

Thanks, that was what I meant. How much would a Maecenas need to pay
to get it finished ?

T.


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions « Newer topic     Older topic »

Create a group - Google Groups - Google Home - Terms of Service - Privacy Policy
©2009 Google