Rule Check - Highscore Tables

If I add a high score table (doubt I’ll have room) does the PHP/JSP that provides the highscore server have to be part of the 4k?

Kev

I like the idea that we should allow games to submit highscores, however we should have a rule that no data should be allowed to be transferred back to the game (other then confirmation of submission).

Maybe Java4k.com could provide a API.

As I understand the rules, you are only allowed to do client/server stuff if both sides are Java programs that fit inside the same 4k. So you would have to give your program multiple entrances or multiple class files, and somehow fit the overhead from that, the overhead from network calls and your actual highscore logic into the 4k. At which point it seems wasteful to spend so much room and not be making a game that’s primarily about some client/server interaction.

All of which is a shame. I would completely support Java4k having an API for this sort of thing, if everyone (especially the people in charge!) was in favour of it.

There was once a game called World Rally Driver 4k that did have a highscore list. I think he submitted a game without highscore, but publicly told everyone to try it with a highscore list. (not sure)

You’re right, there should be an API for this. I’ll talk to jojoh and see if he can quickly provide it.

[s]It’s a simple matter to do. I could provide a URL for a game to invoke to submit a high score. The highscore table would then be shown on the game’s view page on java4k, or I could also have a URL that the game can retrieve in order to show the highscore highscore table ingame as well (or that could be the response to the submit).

Problem is preventing cheating. How can we make this “safe”?[/s]

see below:

Another way is for me to supply a jar, imported in the applet html tag, that has one static method that takes care of submitting the score to the server (and possibly returning a result). That method encrypts the data being posted, and server has the key to decrypt. Not bulletproof, but enough to prevent easy cheating.

Hey. I was on the verge of suggesting this last year. I think it is a really cool idea, and it makes playing the games much more fun IMO. It does break the pure 4K idea a bit and there will have to be a trade-off between adding more features to the game-play or adding high-score, but in general it will be more fun to play the games. If I recall correctly, we decided to judge Rally Driver without the high-score list. I wonder if we should do that again. It is hard to disregard that feature though.

I was thinking that it could work sort of like mochiads high-scores and the likes does it. That way we could gather name and possibly even display highscore list in a “pop-up” inside the applet (overlay). A dev API could also be provided so that it works offline. On java4k the dev can then check if high-score should be used and what format and ordering should be used.

It makes no sense of doing this unless most of you agree with this though, so speak now or forever hold you peace.

nice, however better to avoid putting a pop-up back into the actual applet as that can get messy, much nicer/simpler to just have a separate php page that displays the scores.

Maybe just make it part of the games description page so the scores are visible below the applet and users can config this when submitting/editing their games 4k page.

As for breaking the 4k rule, it does bend the rule slightly but then everyone has equal access to the feature and technically its just throwing a number at some php script. The games also function totally independent of the highscore system, so the feature can easily be disabled and is just an extra feature for visitors of the site. Also highscores are only useful for certain types of games so not everyone will want to use it and can safely ignore it.

Given that most people use active rendering and don’t do it by implementing paint / paintComponent this could be a bit tricky. I suppose that if you supply a java.awt.Image that’s probably compatible with most people’s frameworks, but even then there are fairness questions because the method names or NameAndType string pool entries might compress better for some people than for others.

Active rendering seem to be broken on the lastest mac java anyway.

Kev

Yeah, I just checked and I can’t play Left 4k Dead anymore.

Suck. Maybe it really will be good when Apple drops Java.

There’s no more AWT/Swing heavyweight components with Apples changes (except for Frame, Window, Dialog, etc), they’ve changed it all to lightweight so they can for example render it all through OpenGL (or at least thats the plan).

Now with them joining OpenJDK i believe they’re planning to donate those changes, so they might find themselves into java on other platforms. However Apple have said work isn’t complete yet so it might work in future. So no it won’t be good for games (at least initially), these sort of changes have borked performance on libraries like PulpCore and completely broken JOGL/LWJGL applets too.

Ok, tentatively, this will be added as support in the current contest, if there are no objections.

As long as there are no problems, I’ll make available a jar (both for development/mocking and production), hopefully tomorrow, although I’ll need to test it first.

At least you can make the assumption for your game(s) that this will be supported.

Will the table be displayed on the game page as HTML, or will we be getting the current table back from the API and expected to render it using game logic?

Also, a suggestion: could the jar have several methods that could do the same thing with different names? So even though the actual method is something like sendToHighScoreTable(String, int), there are aliases like drawString(String, int, int) that just call the real thing, but allow people to pick whichever one will compress best for their game.

The single public static method I’m thinking of having in the API goes something like this:

public static String postScore(String playerName, int score);

Returned value: The resulted highscore table in a csv string, e.g. “name1,score1;name2,score2;…;nameN,scoreN”. I thought about returning a List or something like that, but won’t it add to size of the game jar?

That way the developer can choose if he wishes to display the highscore in his game, so player won’t have to reload the web page to see his position. But this is optional, although offered. And yes, it will be displayed on the page for the games that have enabled highscore feature.

The API identifies the game by using a parameter in the applet tag.

Developer can define the order of the highscore list for his game when he submits the game (or edits it). I can be ordered by score either descending or ascending (lower or higher is better). Number of results on highscore might be either 10 or 20, rest is omitted.

Just what I’m thinking.

I had the idea of creating a high score lib to take just the score in a constructor, then applet/image/graphics and returning a boolean for done in an update function. The lib would then take care of getting the user name and displaying the list, so that the impact of adding highscore would be minimal. But if active rendering is not working then it might be problematic, didn’t quite follow what the problem was there.

The code change to use highscore would be to create the highscore object and call it each loop until it returns true. Not sure how to handle username input in a 100% reliable way across platforms nowadays especially that works for most types of games, but I am sure that can be handled collectively if it need be. I have to sync with appel tomorrow so that we head in the same direction.

Then again having just a function that takes just name and score is very simple, so that is elegant, but more bytes will be used to gather user name from inside the game, and more effort will have to be made in order to use this feature, so less games will probably use it.

By the way left 4k dead doesn’t work on OS X and FF, but fine on Safari and Chrome for me. That could be some specific problem with FF on my machine, since many applets don’t work there.

In terms of username input, for logged in users you could add a param tag to the applet and then read that in the library.

Such a long method name :slight_smile:
precious bits being wasted in an environment where one letter methods are common :slight_smile:

Really like the idea of using the site login for the username. Would encourage people outside of the 4k community who play to register.

Kev

Yes, that is exactly what I am doing at games4j.com, but the drawback is that you have to be logged in before starting the game. The encouragement to get into the highscore list is not enough for people to go through a registration process in most cases. I plan to add authentication via facebook gmail and the rest to get rid of the whole registration prcess on games4j to see if that works better. We could possibly test that on java4k as well. You also get rid of all the obscenities that are bound to pop up if anyone can type in anything for name, and the whole clientside lib is ready. I could just take the games4j lib and refactor the calls to one letter names. Serverside stuff still remains.