It is currently Fri Jan 19, 2018 11:07 pm Advanced search

JAVA UNUSABLE

Code won't compile? Found a bug? Post here!

Re: JAVA UNUSABLE

Postby paul_mcquesten » Wed Feb 17, 2010 7:31 am

I am using C++ (poorly), but might it not be possible to help our Java friends without changing your Java installation: How difficult would it be to (quickly) write a JNI routine that replicates the functionality of currentTimeMillis()?

Yes, it would be non-standard Java, and, yes, that is lamentable, but to my mind preferable to all that Java work being for naught.

It seems to me that this Java problem is a (very nasty) glitch in an otherwise very commendable service by the contest organizers. But it is a technical problem. Your challenge is to handle it with grace and courage.

~Paul
paul_mcquesten
Lieutenant
 
Posts: 12
Joined: Tue Feb 16, 2010 5:12 am

Re: JAVA UNUSABLE

Postby dutchflyboy » Wed Feb 17, 2010 10:20 am

You could also try porting it to c#. It's a bit closer to Java than C++ is (at least in my opinion), and is fast enough to be worth writing in (at the moment of writing this, the 8th, 9th, 10th and 17th are all written in c#).
dutchflyboy
Colonel
 
Posts: 57
Joined: Sun Feb 07, 2010 1:08 am

Re: JAVA UNUSABLE

Postby PonkyBot500 » Wed Feb 17, 2010 12:52 pm

The bot called Graharg was in the top 10 repeatedly and keeps being disqualified. There are a couple other top 10 java bots that have done the same thing. As these bots are ranking in the top 2%, it is a bit inconsistent to suggest the authors are not experienced enough to implement a working timing break. It's pretty clear that the JavaVM is set up wrong.

Oh well, there is a note on the starter packs page which says Java isn't working right and to choose a different language. :(
PonkyBot500
Cadet
 
Posts: 2
Joined: Wed Feb 17, 2010 12:38 pm

Re: JAVA UNUSABLE

Postby kevin_flynn » Wed Feb 17, 2010 11:29 pm

mspang, thank you for your post.

I'm glad that any future entrants will have been made aware beforehand that there are issues with supporting Java bots, it's unfortunate there isn't a better resolution, but at least they will start their development in a competitive language.

I don't have a convenient lenny debian image/machine around but I think the JRE version is probably an irrelevance since the problem appears to reside in the sandboxing of the JVM and not in the JVM per se. I think this is evidenced by the fact that the timing issues within the JVM are profound. thedeadwalrus is right that System.currentTimeMillis() must be inaccurate, but my testing indicated that the problems run far deeper; Even fundamental thread calls (such as Object.wait() and Thread.sleep()) are affected. No JVM could make a stable release in that state, so the problem must lie elsewhere.
kevin_flynn
Lieutenant
 
Posts: 17
Joined: Sun Feb 07, 2010 8:25 pm

Re: JAVA UNUSABLE

Postby mspang » Thu Feb 18, 2010 5:35 am

I've adjusted the code to average the time waited over a few turns. This may or may not help with the Java issues, if someone wants to try again.

kevin_flynn, reads to /proc/uptime are just denied so that strategy will not work. I'm pretty sure currentTimeMillis() does actually return the correct time though.
mspang
Colonel
 
Posts: 74
Joined: Fri Feb 05, 2010 1:53 am

Re: JAVA UNUSABLE

Postby txandi » Thu Feb 18, 2010 10:17 am

I'm not sure if this could help but, as the most consuming process is starting the JVM and this is only done once, you could start the java program and wait a few seconds until you provide the first map to it, in this way the JVM is started and the player cannot take advantadge of this extra starting time.
txandi
Cadet
 
Posts: 9
Joined: Sat Feb 06, 2010 3:11 pm

Re: JAVA UNUSABLE

Postby sasp777 » Thu Feb 18, 2010 12:40 pm

mspang is right, currentTimeMillis works just fine. I've also tried with a bot that just waits for 800ms ( using thread.sleep()) and then returns north, which works just fine as well. I timeout only when I am trying to calculate something.

On possible explanation could be that the dynamic memory allocation of the VM is in trouble with all these processes running and the GC pauses get too big. Mspang is is possible to start the VM with

-Xincgc -Xms128M

This will hopefully eliminate the pauses(at least for the first 128 Mbs of allocated ram), but will make the VM slightly slower.






-
sasp777
Lieutenant
 
Posts: 16
Joined: Sat Feb 13, 2010 11:57 am

Re: JAVA UNUSABLE

Postby sasp777 » Thu Feb 18, 2010 8:13 pm

I've managed to get my bot up, but I've limited the amount of computations to about 100 times less than the ones that I am doing in my laptop (which makes the bot pretty bad). thedeadwalrus, your bot seems to be doing pretty well, did you come up with something ? Cause it might be that the VM on the server is really slow ( and that might be all ).
sasp777
Lieutenant
 
Posts: 16
Joined: Sat Feb 13, 2010 11:57 am

Re: JAVA UNUSABLE

Postby thedeadwalrus » Thu Feb 18, 2010 8:31 pm

Haven't come up with anything. My crappy hack is to conservatively estimate the number of nodes that can be evaluated and use that as a hard limit rather than to mess with the system timer. It isn't optimal, but there are more important things to worry about than continuing to mess with it.
thedeadwalrus
Lieutenant
 
Posts: 11
Joined: Fri Feb 12, 2010 3:10 pm

Re: JAVA UNUSABLE

Postby sasp777 » Thu Feb 18, 2010 8:48 pm

I've completely abandoned time-outs and I "estimate" the number of iterations as well, but I am stuck in a ridiculously small number. At this point I am seriously thinking of C# as an alternative...(and asking myself why oh why didn't I do it in python...)
sasp777
Lieutenant
 
Posts: 16
Joined: Sat Feb 13, 2010 11:57 am

PreviousNext

Return to Technical Issues

Who is online

Users browsing this forum: No registered users and 1 guest

cron