Account Options

  1. Sign in
The old Google Groups will be going away soon, but your browser is incompatible with the new version.
Google Groups Home
« Groups Home
<1kb RL Challenge
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
  4 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
 
Numeron  
View profile  
 More options Aug 7 2008, 11:57 pm
Newsgroups: rec.games.roguelike.development
From: Numeron <irunsofastineedafinonmyh...@hotmail.com>
Date: Thu, 7 Aug 2008 20:57:42 -0700 (PDT)
Local: Thurs, Aug 7 2008 11:57 pm
Subject: <1kb RL Challenge
After a lot more work, my <1kb Roguelike has evolved somewhat since I
first posted it, but this is the final version. This challenge was a
lot of fun.

Now a zombie apocalypse game, the game features a zombie which chases
you around. Collecting all the '$' on a level will make the stairs
appear, and on the third level an '&' which is the big $100 gold coin
you came looking for in these zombie infested wherevers. Collecting it
wins you the game. Being slow gets you eaten. The game also supports
the diagonals, and 5 for wait, and is impossible to crash by falling
off the edge of the map.

The code is 948 bytes and written in Java with 2 secondary classes I
wrote in about 5 minutes for better input... only one method called
g() is used by my code and it essentially replicates getch(). I dont
count these in my source size since everyone else seems to be using
libraries and stuff for io as well. Here is the code:

class M{static int k,X=2,Y=X,x,y,g,a=6,b=a,z,l,G;public static void
main(String[] S)throws Exception{for(;;){char m[][]=new char[9][9];l+
+;g=9;for(x=0;x<9;x++)for(y=0;y<9;y++){if(m[x][y]!=36){m[x]
[y]=46;if(Math.random()<.1&&g>0){m[x]
[y]=36;g--;}}if(x>7&&y>7&&g>0)x=y=0;}m[X][Y]=64;m[a][b]=90;boolean
t=true;for(;;z=0){for(x=0;x<99;x++)System.out.println();for(y=0;y<9;y+
+){for(x=0;x<9;x++){System.out.print(m[x][y]);if(m[x][y]==36)z+
+;}System.out.println();}String q="$:"+G+"  L:"+l;if(z<1)m[4]
[4]=l>2?'&':'>';if(X==4&&Y==4&&l>2){q+=" WIN!";l=0;G+=100;}else
if(X==a&&Y==b){q+="
LOST!";l=0;}System.out.println(q);k=F.i();if(l<1)System.exit(0);m[X]
[Y]=46;m[a][b]=46;if(k>48&&k<52&&Y<8)Y++;if((k==52||k==55||
k==49)&&X>0)X--;if((k==54||k==57||k==51)&&X<8)X+
+;if(k<58&&k>54&&Y>0)Y--;if(k>48&&k<58){t=!t;if(t)
{if(X<a&&a>0)a--;else if(X!=a&&a<8)a++;if(Y<b&&b>0)b--;else if(Y!
=b&&b<8)b++;}}if(m[X][Y]==36)G++;if(m[X][Y]==62)break;m[X][Y]=64;m[a]
[b]=90;}}}}

The easy to read, not compressed onto one line version follows:

class M{
  static int k,X=2,Y=X,x,y,g,a=6,b=a,z,l,G;
  public static void main(String[] S)throws Exception{
    for(;;){
      char m[][]=new char[9][9];
      l++;
      g=9;
      for(x=0;x<9;x++)
        for(y=0;y<9;y++){
          if(m[x][y]!=36){
            m[x][y]=46;
            if(Math.random()<.1&&g>0){
              m[x][y]=36;
              g--;
            }
          }
          if(x>7&&y>7&&g>0)x=y=0;
        }
      m[X][Y]=64;
      m[a][b]=90;
      boolean t=true;
      for(;;z=0){
        for(x=0;x<99;x++)System.out.println();
        for(y=0;y<9;y++){
          for(x=0;x<9;x++){
            System.out.print(m[x][y]);
            if(m[x][y]==36)z++;
          }
          System.out.println();
        }
        String q="$:"+G+"  L:"+l;
        if(z<1)m[4][4]=l>2?'&':'>';
        if(X==4&&Y==4&&l>2){q+=" WIN!";l=0;G+=100;}
        else if(X==a&&Y==b){q+=" LOST!";l=0;}
        System.out.println(q);
        k=F.i();
        if(l<1)System.exit(0);
        m[X][Y]=46;
        m[a][b]=46;
        if(k>48&&k<52&&Y<8)Y++;
        if((k==52||k==55||k==49)&&X>0)X--;
        if((k==54||k==57||k==51)&&X<8)X++;
        if(k<58&&k>54&&Y>0)Y--;
        if(k>48&&k<58){
          t=!t;
          if(t){
            if(X<a&&a>0)a--;else if(X!=a&&a<8)a++;
            if(Y<b&&b>0)b--;else if(Y!=b&&b<8)b++;
          }
        }
        if(m[X][Y]==36)G++;
        if(m[X][Y]==62)break;
        m[X][Y]=64;
        m[a][b]=90;
      }
    }
  }

}

The input stuff I wrote which it works with follows:

import java.awt.event.KeyEvent;
import java.awt.event.KeyListener;
import javax.swing.JFrame;
import javax.swing.JLabel;
public class F{
  public static JFrame frame;
  public static Keyboard vKeyboard;
  public static int i(){
    if(frame == null){
      frame = new JFrame();
      frame.setSize(305, 50);
      frame.add(new JLabel("This Window is used for input as long as
it has focus"));
      vKeyboard = new Keyboard();
      frame.addKeyListener(vKeyboard);
      frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
      frame.setLocationRelativeTo(null);
      frame.setVisible(true);
    }
    int key = -1;
    while(key == -1){
      frame.requestFocus();
      try{ Thread.sleep(50); }
      catch(Exception e){ System.out.println(e); }
      key = vKeyboard.key;
      vKeyboard.key = -1;
    }
    return key;
  }

}

class Keyboard implements KeyListener{
  public int key;
  public Keyboard(){}
  public void keyTyped(KeyEvent e){}
  public void keyReleased(KeyEvent e){}
  public void keyPressed(KeyEvent e){ key = e.getKeyChar(); }

}

-Numeron

 
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.
Numeron  
View profile  
 More options Aug 8 2008, 12:11 am
Newsgroups: rec.games.roguelike.development
From: Numeron <irunsofastineedafinonmyh...@hotmail.com>
Date: Thu, 7 Aug 2008 21:11:39 -0700 (PDT)
Local: Fri, Aug 8 2008 12:11 am
Subject: Re: <1kb RL Challenge
Quick bugfix:

if(X==4&&Y==4&&l>2){q+=" WIN!";l=0;G+=100;}

Should be

if(X==4&&Y==4&&l>2&&z<1){q+=" WIN!";l=0;G+=100;}

This pushes the game up to 953 bytes :)

-Numeron


 
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.
Slash  
View profile  
 More options Aug 8 2008, 12:18 pm
Newsgroups: rec.games.roguelike.development
From: Slash <java.ko...@gmail.com>
Date: Fri, 8 Aug 2008 09:18:50 -0700 (PDT)
Local: Fri, Aug 8 2008 12:18 pm
Subject: Re: <1kb RL Challenge
On Aug 7, 11:11 pm, Numeron <irunsofastineedafinonmyh...@hotmail.com>
wrote:

> Quick bugfix:

> if(X==4&&Y==4&&l>2){q+=" WIN!";l=0;G+=100;}

> Should be

> if(X==4&&Y==4&&l>2&&z<1){q+=" WIN!";l=0;G+=100;}

> This pushes the game up to 953 bytes :)

You could try libjcsi, it makes console support less cumbersome :)

> -Numeron

--
Slashie

 
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.
Slash  
View profile  
 More options Sep 2 2008, 1:06 pm
Newsgroups: rec.games.roguelike.development
From: Slash <java.ko...@gmail.com>
Date: Tue, 2 Sep 2008 10:06:32 -0700 (PDT)
Local: Tues, Sep 2 2008 1:06 pm
Subject: Re: <1kb RL Challenge
On Aug 7, 10:57 pm, Numeron <irunsofastineedafinonmyh...@hotmail.com>
wrote:

SNIP

Ok here it goes with some small adjustements to use libjcsi, so it is
now flickerless and wont need a separate window for input! It runs
over 882 bytes now (no IO included, didnt want to mess too much with
the original source so it is kept as a separate class as the original.
With some adjustments all would fit <1024 bytes)

class N{static int k,X=2,Y=X,x,y,g,a=6,b=a,z,l,G;public static
void main(String[] S)throws Exception{F.c();for(;;){char m[][]
=new char[9][9];l++;g=9;for(x=0;x<9;x++)for(y=0;y<9;y++){if(
m[x][y]!=36){m[x][y]=46;if(Math.random()<.1&&g>0){m[x][y]=36;
g--;}}if(x>7&&y>7&&g>0)x=y=0;}m[X][Y]=64;m[a][b]=90;boolean t
=true;for(;;z=0){for(y=0;y<9;y++){for(x=0;x<9;x++){F.p(x,y,
m[x][y]);if(m[x][y]==36)z++;}}String q="$:"+G+"  L:"+l;if(z<1)
m[4][4]=l>2?'&':'>';if(X==4&&Y==4&&l>2&&z<1){q+=" WIN!";l=0;
G+=100;}elseif(X==a&&Y==b){q+="LOST!";l=0;}F.p(0, 15, q);k=
F.i();if(l<1)System.exit(0);m[X][Y]=46;m[a][b]=46;if(k>48&&
k<52&&Y<8)Y++;if((k==52||k==55||k==49)&&X>0)X--;if((k==54||k==
57||k==51)&&X<8)X++;if(k<58&&k>54&&Y>0)Y--;if(k>48&&k<58){t=!t
;if(t){if(X<a&&a>0)a--;else if(X!=a&&a<8)a++;if(Y<b&&b>0)b--;
else if(Y!=b&&b<8)b++;}}if(m[X][Y]==36)G++;if(m[X][Y]==62)
break;m[X][Y]=64;m[a][b]=90;}}}}

... and the IO

import net.slashie.libjcsi.jcurses.JCursesConsoleInterface;
class F {
        static JCursesConsoleInterface c = new JCursesConsoleInterface();
        static int i(){return c.inkey().code - 69;}
        static void p(int x, int y, String ch){c.print(x,y,ch,7);}
        static void p(int x, int y, char ch){p(x,y,ch+"");}
        static void c(){c.cls();}

}

It can be downloaded here: http://www.roguetemple.com/1kbrls/energonAbsorber2.zip

Run energonAbsorber.bat for the (almost) original version and
energonAbsorber2.bat for an enhanced version

Hope you like it ;)

> -Numeron

--
Slashie

 
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 »