[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/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/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 - Clock Watching

It is currently Thu Jul 19, 2018 7:30 pm Advanced search

Clock Watching

Share and discuss ideas for your entries here.

Clock Watching

Postby tronner » Sat Feb 20, 2010 12:49 pm

Hi,
What's the best way to watch the clock?
In C++...
I tried setting a variable startTime = (double)clock()/CLOCKS_PER_SEC at the start of my make_move() function.
Then bail out of everything after (double)clock()/CLOCKS_PER_SEC - startTime > 0.5.
Which means I shouldn't have any issue with running out of time but I was. Is this not the correct way to do such a thing?
The program runs fine locally and does not cause Tron.jar to default my program. But, on the server I get 'submission suspended.
tronner
Cadet
 
Posts: 1
Joined: Sat Feb 20, 2010 12:44 pm

Re: Clock Watching

Postby txandi » Sat Feb 20, 2010 4:58 pm

txandi
Cadet
 
Posts: 9
Joined: Sat Feb 06, 2010 3:11 pm

Re: Clock Watching

Postby IAmNon » Sat Feb 20, 2010 5:02 pm

IAmNon
Cadet
 
Posts: 1
Joined: Wed Feb 17, 2010 7:48 pm

Re: Clock Watching

Postby grogers » Sat Feb 20, 2010 6:13 pm

I use gettimeofday(), it should provide a more accurate clock than the C clock(). Another thing to note, you should keep your variables as integers, not casting to floating point, because you may lose precision in the subtraction. That may not be happening here, but maybe it is.

Another issue is how much work your program has to do after it knows it is time to respond to the server, and how often it checks the clock. If you have to deallocate a ton of internal state, that could be a problem and make your bot time out.

It seems like the server is a bit slower than a fast computer (or maybe just loaded down), so you may want to adjust accordingly.
grogers
Lieutenant
 
Posts: 15
Joined: Fri Feb 19, 2010 4:08 am

Re: Clock Watching

Postby DjinnKahn » Sat Feb 20, 2010 6:28 pm

I was having trouble with clock(), too. It's because it returns how much CPU time your process has used, NOT how much wall-clock time has passed.
DjinnKahn
Lieutenant
 
Posts: 18
Joined: Wed Feb 17, 2010 11:32 pm

Re: Clock Watching

Postby amstan » Sat Feb 20, 2010 6:44 pm

Yep, and the engine kinda counts wall clock from what i heard.
Alexandru M. Stan
Contest Organizer
User avatar
amstan
Contest Organizer
 
Posts: 691
Joined: Sun Jan 31, 2010 4:02 am
Location: Stoney Creek, Ontario

Re: Clock Watching

Postby ebrahim » Sat Feb 20, 2010 7:40 pm

Another approach is using signals. Search for "setitimer" in forum.
ebrahim
Lieutenant-Colonel
 
Posts: 49
Joined: Mon Feb 08, 2010 7:03 pm

Re: Clock Watching

Postby Maxime81 » Mon Feb 22, 2010 4:08 am

I'm not sure to understand...

Why choosing wall clock and not CPU time ? For now, I estimate how deep in my search I can go and I am never suspended because my estimation is not so bad (low estimation)...

But I am worried about one thing : If the server is really too overloaded and laggy, I risk to not answer in time ?
Maxime81
Lieutenant-Colonel
 
Posts: 42
Joined: Sat Feb 13, 2010 10:56 pm
Location: INSA Toulouse, France

Re: Clock Watching

Postby amstan » Mon Feb 22, 2010 5:40 am

There are problems with the clocktime implementation on the engine side, it was even less reliable than wall time.
Alexandru M. Stan
Contest Organizer
User avatar
amstan
Contest Organizer
 
Posts: 691
Joined: Sun Jan 31, 2010 4:02 am
Location: Stoney Creek, Ontario

Re: Clock Watching

Postby BlackWave » Mon Feb 22, 2010 5:30 pm

BlackWave
Cadet
 
Posts: 5
Joined: Mon Feb 08, 2010 2:28 pm

Next

Return to Strategy

Who is online

Users browsing this forum: No registered users and 0 guests

cron