First try for the 1KB competition

Skip to first unread message


Sep 22, 2009, 11:06:46 PM9/22/09
import*;import java.util.*;class hello{String
i;BufferedReader I = new BufferedReader(new InputStreamReader
(;Random r = new Random();int X=0,Y=0;hello(){try{Byte[] x
= new Byte[24*78];byte[] y = new byte[24*78];r.nextBytes(y);do {for
(int z=0; z<24; z++) {System.out.println();for(int Z=0; Z<78; Z++){x
[z*Z]=new Byte(y[z*Z]);System.out.print((X==Z)&&(Y==z)?'@':x
[z*Z].intValue()%2==1?'#':' ');}}i=I.readLine();X+=a("a")?-1:a("d")?
1:0;Y+=a("w")?-1:a("s")?1:0;}while(!a("q"));}catch(IOException e){}}
public boolean a(String v){return i.equals(v);}public int b(Byte n)
{return n.intValue();}public static void main(){hello h = new hello

Move using wasd, and press enter, quit using q, and press enter. All
you can do is move through the clouds that are randomly generated. It
will play on the terminal.

I chose to see if I could try doing a rougelike with just core input,
random java libraries, but all you can do now is move through the
clouds, represented by #. The final file came out at 657 bytes. Can
someone tell me what other features it needs to have, as I am new to
the competition.

Gelatinous Mutant Coconut

Sep 23, 2009, 1:06:19 AM9/23/09
I was also inspired to try my hand at a tiny RL. We might as well keep
all of these in one thread, eh? :) Mine's not a full game yet anyways.

Here's the code so far, coming out to 365 characters. (382 counting
the terminal command to compile it.) Paste it into "rl.c" and compile
with "gcc rl.c -lcurses".
#define R ((r=69069*r+1234567)<0?~r:r)
#define L i=a+1;while(--i)
#define _ m[i]
int main(){initscr();raw();int r=380116160,w=80,h=22,a=w*h,m

It's pretty simple at this point: You're an @ in an empty rectangular
room surrounded by walls on all sides, and can move around by pressing
1 2 3 4 6 7 8 or 9, until you get bored. Press escape to quit.

I'm really pleased with the R macro, the random number generator.
(Despite the fact that I don't use it yet!) It's stolen from the
Congruential Generator documented in (
statistics/Password/MarsagliaPost.txt), but instead of using an
unsigned long (too many characters) I use a regular int and twiddle
bits to make the macro always evaluate positive. Even when I do use it
it costs me more characters than if i had just gotten rand() from
#include <stdlib.h>, but I like it anyways.


Sep 24, 2009, 8:05:54 AM9/24/09
On Sep 23, 12:06 am, Gelatinous Mutant Coconut

Is this an official <1KBRL Challenge?


Gelatinous Mutant Coconut

Sep 24, 2009, 2:28:18 PM9/24/09
On Sep 24, 8:05 am, Slash <> wrote:
> Is this an official <1KBRL Challenge?

Heh, I don't know if anyone has made it official.


Oct 4, 2009, 11:03:59 AM10/4/09

Ok, first off, this doesnt work as it doesnt have a valid main
method :)

Second, I dont know how useful this is, but I couldnt help myself and
made some basic modifications, result is 619 bytes

import*;import java.util.*;class h{String i;BufferedReader I

= new BufferedReader(new InputStreamReader(;Random r=new

Random();int X=0,Y=0;{try{Byte[] x=new Byte[24*78];byte[] y=new byte

[24*78];r.nextBytes(y);do{for (int z=0;z<24;z++) {System.out.println

();for (int Z=0;Z<78;Z++){x[z*Z] = new Byte(y[z*Z]);System.out.print

((X==Z)&&(Y==z)?'@':x[z*Z].intValue()%2==1?'#':' ');}}i=I.readLine();X

(IOException e){}}boolean a(String v){return i.equals(v);}int b(Byte n)
{return n.intValue();}public static void main(String[]s){new h();}}



Oct 5, 2009, 11:47:56 PM10/5/09

Thanks Slashie. I like some of the changes you made, and saw the
things that were unnecessary.

I think I am going to get started with roguelike programming. I have
tons of ideas, some that may even spawn a new 7DRL.
Anyways, I will try to program something in java, with short code, but
enemies ;).

Reply all
Reply to author
0 new messages