Poll: Are you entering this year's 4K competition?

The Java 4K competition is a chance for Java developers to show off their skills, and face a grueling coding challenge like no other. It requires developers to know anything and everything about how Java works in order to squeeze that last bit out of their program.

I’m curious to know if any of you will be entering this year’s competition. If you’re not, tell us why! :slight_smile:

Here’s some 4K games from previous years:

Abuse’s 4K Shooter
Defender 4000 and WarGames
Tube Blazer
Magic Cutter
Space Invaders 4K
4K Racing Applet

(That’s about as many as I’m going to track down. Feel free to add yours.)

Current entries this year are:

JM4K by Onyx
Meat Fighter 4K by MDB47

I’m definitely entering (although I’m still not entirely sure what my entry is gonna be- call me a procrastinator if you want!)

I think the contest is a great idea, it’s amazing what you can pull off with only 4k. Plus you learn lots of ways to optimize code. ;D

ps - the above link for “Magic Cutter” is wrong, the site has moved. You can find the game at its new location here

“of course” haha ;D

Well, 4k is nuts. Really. But I’m glad that I finally finished it.

And I already decided what I’ll do for j4k mk4. It’s less insane, but even more like a game (with like 20 levels) :slight_smile:

Nice list btw. Those are my favorite 4k games. The annoying bit is that most of em don’t run anymore with 1.5… “corrupted jar yadda yadda”… but actually it’s because “Manifest-Version: 1.0” is missing in the manifests. D’oh. (Just run em manually).

[quote]And I already decided what I’ll do for j4k mk4. It’s less insane, but even more like a game (with like 20 levels) :slight_smile:
[/quote]
Well, you’ve got two months. Do it this year! You can even use the tools I released to shave off development time. :wink:

[quote] The annoying bit is that most of em don’t run anymore with 1.5… “corrupted jar yadda yadda”… but actually it’s because “Manifest-Version: 1.0” is missing in the manifests. D’oh. (Just run em manually).
[/quote]
Actually, all they need is an extra carriage return in the Manifest. For example, a Manifest for jm4k.jar would look like:

Main-Class: D



Versions of the JAR format prior to 1.1 were pretty lenient on getting the carriage returns right. Thus the JVM lets JARs with the “Manifest-Version: 1.0” go through. Of course, we 4K programmers strip out all the auto-generated stuff, so that attribute is missing. :wink:

Well, you’ve got two months. Do it this year!

Nah.

Uhm… maybe. Need to catch up with my master plan. Well, I’ll see.

You can even use the tools I released to shave off
development time.

I won’t use any images. I need 8 different rather simple tiles, which I’ll just draw with Java2D methods. fillRect, drawLine and some gradients is everything I’ll need :slight_smile:

If I’m going to spend any time writing applets, they’re going to be slick enough to put on my website! I don’t really feel like entering any more competitions…

Cas :slight_smile:

Naw.

I compressed data from 4 TB to over 30 GB, if I’d compress them more I’d go under shannon limit. ~_^

[quote]Naw.

I compressed data from 4 TB to over 30 GB, if I’d compress them more I’d go under shannon limit. ~_^
[/quote]
Eh? I can compress 4TB to 6 bytes with no problem. Here’s a hex dump of the encoded data:

04 00 00 00 00 00 FF

And here’s the decompressor:


long length = 0;
long counter = 0;
int b;

for(int i=0; i<6; i++)
{
  length <<= 8;
  length |= in.read();
}

b = in.read();

while(counter < length)
{
  out.write(b);
  counter++;
}

;D

I was considering entering so I had a go, man this is difficult! One simple class that create a frame etc is 1k !

Have I forgotten some command line switch (-makeitsmall) ?

Kev

well you always have -g:none which will strip out all of the debugging info. Sometimes the -O flag can also reduce class size, but sometimes it can also enlarge it. Test that one carefully.

When you jar the game up, don’t forget you can pass the M flag which will skip the manifest entry altogether. The rules say the game must be executable from the command line, it didn’t say it had to be self executable :stuck_out_tongue:

That’s really all the compiler flags I can think of that has anything to do with class size. And really you shouldn’t worry too much about the size of one class, because you’re probably only going to use one class for the entire game.

Just to be sure here, a jar file that is under 4096 bytes is ok? The class inside could be larger? Or is that against the rules?

Kev

yes, the class inside can be larger. The final package of the game and its resources must be <=4096bytes. Since this is the case, most entries will definitely be jars.

by the way… I just remembered one of the great tricks Abuse uses.
Consider this class that creates a frame:


import javax.swing.*;
import java.awt.*;
public class G extends JFrame {
      public G() {
            super("Game");
            show();
      }
      public static void main(String args[]) {
            new G();
      }
}

When compiled normally, the class size is 336bytes. When compiled with the -g:none flag, the class is 252 bytes.
But notice this neat trick Abuse uses:


import javax.swing.*;
import java.awt.*;
public class G extends JFrame {
      public G() {
            super("Game");
            show();
      }
      /* public static void main(String args[]) {
            new G();
      } */
      static {
            new G();
      }
}

when that is compiled with the -g:none flag, the class size 231bytes. The only problem with this is, the JRE will throw an exception in your face for not having a main method :stuck_out_tongue:

Now with a class that small, JARing it would probably actually enlarge it (I’m too lazy to test though). You don’t need to start JARing until you approach 4K a little closer :wink:

Thanks for the tips!

Last Question until I go off an write my second entrant (or not :)): Is there some formal way I have to submit the entry or is it just a post here type job?

Kev

it would be a good idea to post your entry on both of the “official” posts:
JDC Thread
JGO Thread

I’m gonna give it a whirl. I’ve been doing some testing and I think I can fit a 3d software renderer with flatshaded poly’s using Graphics.fillPolygon() into a 4k jar. My basic applet framework with basic matrix functions is 2.7kb right now (with KeyListener).

I’m guess-stimating I can have up to a 7.0 - 7.5kb class file compress down to 4.096. Does that sound about right?

6kb of code and 1 kb of meshes; I’m gonna have some nasty data management with no other classes (maybe one big float[] for verts, normals, triangle indexes and colors… ??? )

We’ll see…

I think you could save some bytes by ditching the matrix stuff and do the transformations directly with sin/cos.

http://web.archive.org/web/20030804050840/http://www.saber-x.com/midgarddesign/4k.html
Archive.org rocks :slight_smile:

Ohh, and my entry really will suck
;D

[quote]I was considering entering so I had a go, man this is difficult! One simple class that create a frame etc is 1k !

Have I forgotten some command line switch (-makeitsmall) ?

Kev
[/quote]
Now… in retrospect… I think that post is kinda funny ;D

Smart arse. But yeah… this year compo has proved to be a great success. Quality games and lots of them (well, apart from some of my entries ;))

Kev