[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/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 - C# debugging time out issues

It is currently Mon Jul 16, 2018 8:21 pm Advanced search

C# debugging time out issues

Topics about starter packages, visualizer or any other third party tools.
Please submit new language requests in the Language Request Forum.

C# debugging time out issues

Postby vzero » Thu Dec 01, 2011 8:44 pm

Hey guys,

I've been having a lot of issues with my bot timing out. I've tried the following:

- Placed a lot of checks for GameState's TimeRemaining and stop existing processes/work if it is taking too long
- Do time checks in every loop in my code
- Having my bots do nothing if there's too little time
- Added comments in my Error log to monitor time remaining
- Limited the number of times I path find in a turn

There are a lot cases where i see there's xxx ms left and the next line is timed out such as:
Time Remaining: 335ms
turn 82 bot 0 timed out

I would be expecting another "Starting to do blah" comment in my error log before the "turn xx bot 0 timed out" as I've placed comments everywhere literally. So I'm not sure what's going on as there's nothing really happening when my bot timed out.

Can anyone give me some tips on reducing the chances of my bot timing out?

Thanks in advance.
vzero
Cadet
 
Posts: 6
Joined: Fri Nov 04, 2011 8:50 pm

Re: C# debugging time out issues

Postby gnu264 » Fri Dec 02, 2011 5:32 pm

IIRC the C# starter package uses DateTime.Now for measuring time, which is only exact to ~16ms. If you want better measurements, you'll have to use the Stopwatch class.
Still, this wouldn't explain a 335ms difference... since the starter package scripts (playgame.py etc.) seem to work well for thousands of people, it has to be a bug in your code. Does it always timeout in the same piece of code?
gnu264
Captain
 
Posts: 23
Joined: Tue Nov 08, 2011 5:27 pm

Re: C# debugging time out issues

Postby romans01 » Fri Dec 02, 2011 6:15 pm

C# is too slow to win this game. Bound checking effectively kill performance. Drop c# and port to java if you have time.
romans01
Major
 
Posts: 31
Joined: Thu Oct 27, 2011 11:23 am

Re: C# debugging time out issues

Postby vzero » Fri Dec 02, 2011 6:23 pm

gnu264:
You have a good point. I do believe it is a problem in my code as there's at least 10 players that are top 100 and is using C# who isn't timing out often.

The time out usually occurs just after finding a path but before starting on the next task. I guess I should check the end of my path finding code to see if it is doing something when returning the path.

And what's more strange is that I'm seeing more time outs online than in my local development environment (even on the cell maze maps). I'll try using the C# Mono compiler; currently I am compiling the executable using Visual Studio 2010.

Thanks for the help.

romans01:
Thanks but I'm actually playing this game to learn how to improve the performance of my code in C#.

edit: semantics
vzero
Cadet
 
Posts: 6
Joined: Fri Nov 04, 2011 8:50 pm

Re: C# debugging time out issues

Postby bugnuts » Fri Dec 02, 2011 6:50 pm

romans01: It's surprising that bounds checking would matter much one way or the other and the fact that current standings have #2 and #3 bots written in Go (with bounds checking) makes me think you are mistaken in your assumption.
bugnuts
Lieutenant
 
Posts: 11
Joined: Mon Oct 31, 2011 3:02 pm

Re: C# debugging time out issues

Postby romans01 » Fri Dec 02, 2011 8:02 pm

romans01
Major
 
Posts: 31
Joined: Thu Oct 27, 2011 11:23 am

Re: C# debugging time out issues

Postby vzero » Fri Dec 02, 2011 8:17 pm

On the bright side, if what you say is true then it shows that the C# players who made it to top 100 are really good coders! :lol:
vzero
Cadet
 
Posts: 6
Joined: Fri Nov 04, 2011 8:50 pm

Re: C# debugging time out issues

Postby bugnuts » Fri Dec 02, 2011 8:22 pm

Well there are 721 C# submissions and 1901 Java submissions, so 30 * 721/1901 = 11.4. (and there are actually 11 c# ones in the top 100) so it seems to be equally probably for either language to reach the top 100, just fewer c# submissions.
bugnuts
Lieutenant
 
Posts: 11
Joined: Mon Oct 31, 2011 3:02 pm

Re: C# debugging time out issues

Postby romans01 » Fri Dec 02, 2011 8:32 pm

romans01
Major
 
Posts: 31
Joined: Thu Oct 27, 2011 11:23 am

Re: C# debugging time out issues

Postby ronnyk » Sat Dec 03, 2011 1:08 am

Did a bit of testing on this tonight. With Visual Studio though so it shouldn't apply to the Ants game, but I figure the results might be somewhat interesting anyway... plus I've been itching to test this for a long time ;)

int[] anArray = new int[100000000];
for (int i = 0; i < 100000000; i++)
{
anArray[i] = i + i;
}

Running this loop 10 times took about 1.81 seconds on my computer. About 0.05 seconds longer if i did a call to the loop-function before starting the timer. Not quite what I was expecting but that's how it went...

When removing the bounds-checking with unsafe/fixed the x86-compilation goes from 2.03 to about 0.01 seconds faster. (note that you're not required to use bounds checking with C#)

However, for x64 it removes the bounds-checking if you use a constant size even with safe code. Except for when the array was too small, only then did the JIT emit bounds-checking code.

And for some reason, in this test when using a variable to store the array size the code ran slightly faster with bounds-checking than without it. I guess in some cases bounds-checking can be good in multiple ways ;)

Then when comparing that loop with VC++ code using all optimizations, the constant size took a little longer (about 0.04) and variable size went faster (by about 0.13). I probably did things wrong when comparing this, but the speed can't be all that different. It would probably be more interesting to try with less memory and more calculations instead.

Still, if Java was 10 times faster then there was likely something fishy going on ;)
ronnyk
Cadet
 
Posts: 5
Joined: Sun Nov 13, 2011 3:11 pm

Next

Return to Starter Packages & Tools

Who is online

Users browsing this forum: No registered users and 1 guest

cron