aichess

I can’t access the javaunlimited site from here, so I can’t check who it was that submitted this game (not me), but… if you’ve been hanging out at this board and haven’t seen this game yet, you owe it to yourself to try it out.

I am not a great chess player - hell, I’m probably not even a good chess player - but this game is incredible for 4k. I have managed 2 wins and 2 draws against about 20 or so losses.

Maybe someone with access to both sites can post the link here so that others can enjoy? Thanks.

To the author: congratulations. This is easily one of the top 5 games, if not top 3.

I would repeat what you have said EnderGT! Awesome!

http://ulf.ofahrt.de/aichess4k/

It is fast
It is too good
It has even undo (right clicking)

Thank you, whomever made that!

Best regards from

The author is UlfJack (or at least that’s the nick he uses on IRC), and he’s been trying to join these forums for some two weeks or something such. No admin has accepted him yet, but I would expect to see him around soon.

And I agree with you all, it’s an awesome 4k game. Bloody awesome.

Yep, he should get a platinum user account here. To at all think about doing a chess game in 4K is just mad. To actually do it is a super accomplishment, and to make it look and play so well might be the best technical feat of the 4K compo all time. Think this even beats realtime raytracing in 4K. Next rayraced chess :smiley: I am deeply impressed!

Heja, I’ve found a way to save another couple of bytes, so watch out for animations to come soon. :wink:

Btw. the castleing rule is not implemented 100% correct. Right now, you can’t castle if the rook is under attack or would move through an attacked square. And there might be problems with some of the other more exotic rules (draw after 50 moves without taking a piece or moving a pawn, and draw after 3 times back-and-forth).

Got animations, undo/restart buttons, a button to change the difficulty level (easy,hard,impossible), and fixed the castleing bug. And still just under 4k. ;D

The third difficulty level may be a tad slow. :wink:

3rd level? Hell, the 2nd level is taking several minutes to decide on a move on my machine (2.0 GHz Pentium M, 1 GB RAM). I’d hate to see how long the 3rd level would take! While computer is deciding on a move, the screen does not repaint (i.e. if I switch applications and come back, the screen is blank until the computer decides to move.) A different painting strategy might fix this. Also, some indication that the computer is still thinking might be nice - if you have the room, maybe make the mouse cursor into the busy icon? Also, you probably shouldn’t be able to change difficulty levels mid-game, although I’m not sure how to fix this.

The animation is a very nice addition, helps to identify what move was just made. My only complaint is that the captured piece disapears before the moving piece arrives - this is a bit confusing on long piece moves. Maybe wait until the moving piece is only 1 square away before removing the piece?

And my final complaint - even on easy, it’s too damn hard ;D

Very, very, very well done.

  1. no repaint while ai is working
    While this is technically not difficult, I’d have to restructure some of the internal data structures.
    thinking
    Will see if I can fit it in.

  2. doesn’t show that ai is working
    Well, it does show that it’s Black’s move, so as such, there is an indicator that the ai is working. I understand that changing the mouse cursor would be nicer (and a progress bar would be nicer still). I don’t see either happening if I don’t find a way to save another couple of bytes.

  3. piece disappears before the other piece gets there
    That is an artifact of how I do the animation. I can think of a different way (of doing the animation), but am not sure if I can fit it in.
    thinking
    Will see if I can fit it in.

  4. the ai is too difficult
    I already thought about this and I think that there might be a way to make the easy mode easier…
    Will see if I can fit it in.

Thanks for testing and feedback! Although I can’t promise that any of those things actually is going to change. It’s already a pretty tight fit as-is. Although I already thought that the last version was a tight fit and I ended up saving ~350 byte.

If you need to optimize more, then post the code… pretty sure we can save you up to 100 bytes easily :slight_smile:

Understood. Please don’t take my feedback as criticism - I think you’ve done a fantastic job, and it just keeps getting better.

And yes, please do post the code, if you can. I’d love to see how you did it, in addition to trying to help in finding places to save space.

Well, just by using the 4KJO tool with the published JAR file i was able to reduce by 158 bytes to 3923 bytes. (see attached)

If i had access to the source I would be able to further reduce it approximately another 150 bytes and bring it down to about 3800 bytes. This would be done by modifying the source such that the code to create the frame etc will be in the constructor and then remove the static main method. I would then create a pack200 archive and embedd into a class which loades this embedded pack200 archive.

Woogley has spoken - Pack200 is permissable so long as the final jar file is self-executable.

hmm, I would have though woogley would have spoken on this matter, may be he is on holidays? I will send him a PM.

Sure, the source code can be found here (NOTE: this file may or may not be updated to the latest version):

http://users.conquer-space.net/~ulf/aichess4k/aichess4k.java

I would be interested to hear any easy, yet significant optimizations (please don’t waste time with changing | to || or something like that). I will have a look at the 4KJO tool.

My current approach at packing this into a jar is as follows:

  1. compile with javac from sun 1.5.0_10
  2. jar
  3. optimize with proguard (http://proguard.sourceforge.net/)
  4. unzip and rezip with kzip (http://advsys.net/ken/utils.htm)

Looking at the source, I feel like it could do with a couple more comments. I’m happy to answer questions about the source and algorithms, here or in irc (#lwjgl on freenode).

PS: I’m on linux here, so I can’t use the 4KJO tool directly.

PPS:

  1. no repaint while ai is working
    Disregarding any potential race conditions, I can do this in about 4 bytes.

  2. doesn’t show that ai is working
    This is damn expensive, at about 83 65 45 bytes.

  3. the ai is too difficult
    Weighting in at 3 byte. It’s so damn stupid at the first level, I have to make the second level the default level.

PPPS:
And another go at ai settings. Now it’s actually saving space, and IMHO, it’s easier to beat at the easy level. And even the third level is actually playable in terms of performance.

New version is up, new source is up, and it’s still below 4096. Testing and feedback is welcome.

I have been getting better results with 7zip over Kzip. Also I tried BJWflate and got another 10 bytes over 7zip. Unfortunately BJWFlate is Windows only.

Also excellent job. I play some chess and can beat all 3 levels. However to fit how well it plays into 4k is amazing. I think you should increase the difficulty of level 3 a little more if you can.

Made a big mistake when I rewrote the ai levels (the second and third were way too easy). That’s fixed now.

Great job. One suggestion the black pieces on the black squares are hard to see on my monitor, maybe red on black or black on red would be eaiser to see.

Fantastic job. I’ve found myself playing it for fun on several occasions.

I will see if I can get a better color scheme in.

I’m just realizing that noone bothered to post a link to the JNLP, so here it is:
http://javaunlimited.net/games/launch.php?type=jnlp&id=117

I’ve put in a new color scheme for the board: orange on orange
It’s bright, but the pieces are better visible. Let me know what you think about it.

Cheers!