Poker4k

This will be my first 4k entry ever… wooh!

The fake 3D renderer took about one third of the code, gameplay and AI fill the gap. The jar is exactly 4096 bytes. All rules of standard poker are implemented, you only can’t bet for ingame coins yet. Their purpose is decoration :slight_smile:

The AI does a bruteforce calculation and manages to swap cards in a perfect way.

For those new to standard poker, or for those who know standard poker and think I messed up on the rules, here is how to play it:

  • click the card-deck to get your cards
  • click on the cards you want to swap, they will raise.
  • click the desk to swap cards
  • you’ll see who won the round
  • click anything to start the new round

Here is the JAR (you’ll have to find the sourcecode yourself :stuck_out_tongue: go for it!)
Here is the JNLP (added mime-types through .htaccess ;D)
And some screenshots:

The game might not be the most thrilling or all entries, I admit, but I’m very proud of it ;D

Looks very impressive, I can’t understand how you managed to get those graphics in 4k… however, it won’t start. Lack of manifest file?

(Says invalid or corrupt jar file, so there might be some other problem).

EDIT: Worked when I extracted class via winrar and fired it up manually. Very impressive graphics, albeit slow - it takes a long time to do most things :confused:

Same here, cannot run the jar file.

java -cp A.jar A

to get around the missing manifest >:( :-[ The JNLP version will solve that, right?

Oh, and it uses Java 1.5 (nanoTime for smooth gfx)

Yep, the JNLP should fix that. However, contest rules says 1.4.2, so I guess nanoTime’s not allowed?

EDIT: That source code was well hidden, haha :smiley:

EDIT2: I’m really impressed with this one - you all manage to get your graphics so awesome :>

Pretty cool and very nice graphics! Card animations are great too!

How about adding some stats: e.g. you automatically bet $10 per
hand. So you see: “Won 7/10 hands” / “Total Earnings: $20” or
something like that?

Yup, thanks for the feedback! I was thinking some stats too, but ATM I have no space for it unfortunately.

I think I can optimize a lot to get back some bytes. Adding stats is the first thing on the todo-list :-*

Mind to share some specs?

It works smooth on a P4 1.8

P4 2.4 Ghz, XP Pro… runs smoothly, but has long loading times (that is, it takes a few seconds before I get to see the cards after I get them).

Also, I had two aces and lost versus Bill (who had a pair of fours). That doesn’t seem right? :slight_smile:

Holy sweet looking graphics, batman!

I really like those shadows. =)

Hehe… you found the bug!

Aces are worth 1
2’s are worth 2
9’s are worth 9
K’s are worth 13

It’s a heck of a lot work to get that fixed, as most stuff is stored in long long LONGs.

:frowning:

For those who care why:
All suits locations on the cards for each and every card, are stored in 1 long: 768154053244724416L. Finding the position-data is done with bit-shifting. When I make the ace worth more, I have to remove it from the beginning and add it add the end of the cards. so i’d have to re-encode all those longs and, well, I’m not feeling like it! :smiley:

nice graphics :smiley: - but the something that can make you play a game for ages simply misses. It starts to get boring after some time.

Indeed. I consider it a proof-of-concept, until I get betting in, then it might be addicting… it might… “Win the most money in X rounds” … maybe? The replay value still wouldn’t be jawdropping :slight_smile:

I will keep working on the little game to make it better. Feel free to share your two cents!

What about not using the real poker rules, but random generated rules, where you have to think of new tactics every round and so on.
Hmm - the AI would then be rather difficult…
Or you can add a timer, so you’ll only have let’s say 10 secs to make your decision. You could shorten that time for higher levels.

I’m not sure about the timer idea… doesn’t run smoothly enough for that on my computer, I’m sure the ten seconds wouldn’t be enough to make a decision (as it takes at least 5 before I get to see the cards).

Create a file called “A.jnlp” in the same directory as your A.jar file, then put the following code in it:

<?xml version="1.0" encoding="utf-8"?>
<jnlp
  spec="1.0+"
  codebase="http://www.songprojector.com/static/"
  href="A.jnlp">
  <information>
    <title>Poker4K</title>
    <vendor>Riven</vendor>
    <description>A Poker Game with psuedo-3D graphics and AI in 4 kilobytes.</description>
    <description kind="short">A Poker Game in 4K.</description>
    <offline-allowed/>
  </information>
  <resources>
    <j2se version="1.4.2,1.5+"/>
    <jar href="A.jar"/>
  </resources>
  <application-desc main-class="A"/>
</jnlp> 

It can’t be tested anywhere but on the server. That should do the trick. :slight_smile:

P.S. Your JAR file can have a long filename without impacting the size of the JAR itself. It’s always nicer to have something like “Poker4K.jar” instead of A.jar.

Well yes, thank you, although I know how to make JNLP files, I only need a server that had the proper mime-type set.

Maybe modern browsers will ignore the mime-type all together (I know IE ignores a lot of things…) so I’ll give it a go.

Update: IE opens it in its XML editor, bah.

There is not any loading going on, so I think there is something wrong in my timing code. For me it takes 1s (manual delay) to get the cards in standing position. It can be any delay, even 0ms. I’ll try to fine-tune it, or fix a bug that’s causing the delay to last longer.

Oh, sorry. Misread that as “someone get me a JNLP file, quick”. If you need a server, I can provide. Just let me know. :slight_smile:

P.S. Even if the MIME type is wrong, users can always download the JNLP then execute it.

Found another bug.

I had AQJT6

Computer AQ542

And it said that I lost. This wouldn’t be the Ace bug, because we both had aces.

ps. Nice job with the 3D. Works smooth on my machine. AMD Athlon 64 3000+, 512MB, ASUS Radeon 9600PRO