[phpBB Debug] PHP Warning: in file /includes/bbcode.php on line 483: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file /includes/bbcode.php on line 483: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file /includes/bbcode.php on line 483: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file /includes/bbcode.php on line 483: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file /includes/bbcode.php on line 483: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file /includes/bbcode.php on line 483: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file /includes/bbcode.php on line 483: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file /includes/bbcode.php on line 483: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file /includes/bbcode.php on line 483: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file /includes/bbcode.php on line 483: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file /includes/bbcode.php on line 483: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file /includes/bbcode.php on line 483: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file /includes/bbcode.php on line 483: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file /includes/bbcode.php on line 483: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file /includes/bbcode.php on line 483: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file /includes/bbcode.php on line 483: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file /includes/bbcode.php on line 483: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file /includes/bbcode.php on line 483: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file /includes/bbcode.php on line 483: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file /includes/bbcode.php on line 483: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file /includes/bbcode.php on line 483: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file /includes/bbcode.php on line 483: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file /includes/bbcode.php on line 483: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file /includes/bbcode.php on line 483: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file /includes/bbcode.php on line 483: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file /includes/bbcode.php on line 483: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file /includes/bbcode.php on line 112: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file /includes/functions.php on line 4586: Cannot modify header information - headers already sent by (output started at /includes/functions.php:3765)
[phpBB Debug] PHP Warning: in file /includes/functions.php on line 4588: Cannot modify header information - headers already sent by (output started at /includes/functions.php:3765)
[phpBB Debug] PHP Warning: in file /includes/functions.php on line 4589: Cannot modify header information - headers already sent by (output started at /includes/functions.php:3765)
[phpBB Debug] PHP Warning: in file /includes/functions.php on line 4590: Cannot modify header information - headers already sent by (output started at /includes/functions.php:3765)
AI Challenge Forums • View topic - what timing code to use for java

It is currently Fri Apr 27, 2018 8:24 am Advanced search

what timing code to use for java

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

what timing code to use for java

Postby thadeoc » Wed Feb 10, 2010 4:41 pm

Sorry to start another thread about timing, but here goes...

Are there any recommendations for keeping track of time in your environment? At the moment I'm using System.currentTimeMillis() at the start of my move and again in every recursive call to my search function. If more than a certain number of milliseconds have passed I stop going any deeper in the tree. On my machine this works great- I can set any depth I like and the search finishes within 1-5 ms of the timeout, whatever I set the timeout to be (I tried values from 600ms down to 100). So the time taken outside the recursive search plus the time to bail out seems negligible. When I upload this code to the server however it always times out, unless I set the timeout to 1ms. Even 10 ms doesn't work! Restricting the search ply to a certain depth works better, but is still unreliable- I've had bots time out after 20hrs on the leaderboard.

I understand System.currentTimeMillis() might cause a system call, incurring additional overhead. Is this case on your system? would System.nanoTime() be any better? Should I avoid trying to keep track of time at all and just hard code my search depth?

Edit:
I'm aware of the problem with JVM startup time, to get around this I just make a random move as quickly as I can for the first three turns. I just added that fix as I was writing this and it seems to have helped.

As a sidenote, does system load affect the bot timeouts- ie could a bot thats cutting it close to the timeout work fine for a while, then time out during a period of high system load?

Edit: suspended again. It would be pretty helpful to show the games that got a bot suspended along with the won/lost/drawn games. Being able to see at what point your bot timed out would be great!
thadeoc
Cadet
 
Posts: 2
Joined: Fri Feb 05, 2010 1:42 pm

Re: what timing code to use for java

Postby Janzert » Wed Feb 10, 2010 11:15 pm

I finally gave up and moved to C++. With java I was timing out in less than 10 games no matter even if I set the time limit to 10ms. With a straight port of the code to C++ I've landed right around rank 20 and have yet to experience a time out after 60+ games.

My theory now is that the garbage collection pauses are just too long with the JVM.
Janzert
Contest Organizer
 
Posts: 271
Joined: Sun Feb 07, 2010 1:59 am

Re: what timing code to use for java

Postby kevin_flynn » Thu Feb 11, 2010 12:24 am

kevin_flynn
Lieutenant
 
Posts: 17
Joined: Sun Feb 07, 2010 8:25 pm

Re: what timing code to use for java

Postby nakovalnja1976 » Sun Feb 21, 2010 5:44 pm

thanks for information
Find a perfect contractor. Post your project and get the contractors to bid for your business!
nakovalnja1976
Cadet
 
Posts: 1
Joined: Sun Feb 21, 2010 5:43 pm

Re: what timing code to use for java

Postby melkor » Mon Feb 22, 2010 9:52 am

I'm facing this same issue in c++. When I'm running the code on my pc, all moves are always taking 1s but my AI gets suspended anytime between 2-10 games because of a timeout. I changed my code to make a move in 0.1s, but it still gets suspended due to a timeout between 2-30 games. Even after i reduced it to 0.02s, it still times out. I'm using clock_t in time.h to get the time, but im guessing this doesn't work accurately. Can someone tell me a better way of keeping track of time in c++?
melkor
Cadet
 
Posts: 6
Joined: Mon Feb 22, 2010 8:22 am

Re: what timing code to use for java

Postby melkor » Mon Feb 22, 2010 9:55 am

Sorry for the above post, there is already a thread addressing this issue in the stratergy section. viewtopic.php?f=8&t=316
melkor
Cadet
 
Posts: 6
Joined: Mon Feb 22, 2010 8:22 am


Return to Technical Issues

Who is online

Users browsing this forum: No registered users and 1 guest

cron